Session management refactors and unit testing
Updated comment