Guarantee consistent state when changing config.

When changing application configuration options for test runs, I've found it's best to do it in a way that ensures the original state is rolled back to no matter what.

This refactoring guarantees the application is not left in an inconsistent state in case an error is raised during the test run - more specifically as part of the call to `post "/oauth/authorize..."`.