implement logout
add tests, handle errors