Pull logic for how master and user API keys are determinined for testing out of functional_tests.py for reuse elsewhere. This refactoring will help the creation of an API test framework.