Avoid polluting the global namespace in test_files

Move the monkey-patching of the TestConfigFiles class into a class
method. This avoids pollution of the global namespace, improving
compatibility with different test harnesses.