fixed tests and bugs in session handling