Added the authorization check and the tests to go with it