add session test, small refactoring