Update the authentication unit test for the changes to authorization.
This also fixes several bugs found though the unit tests.
In addition change the mock database so that it can be configured when to throw an exception.