Handle unauthorized exception in tests.