Fix bug in test_session