Add MainCtrl.deauthenticate and improve tests