Clear queue when message loop is stopped
Add thread's id
Refactor session
Fix typo in session tests