Logout tests and some code tidying
Can now logout