Adding UnauthenticatedException and unit tests