Refactoring of close session, commit, rollback methods