Fix session API tests
Fix some HTTP status codes in sessions API
Clean up sessions code from static analysis