Improved login and csrf tests.
Moved login, logout, and csrf into BaseHandler.