It's rare that code should belong outside of any function or class.  Looking things over, I think this code would best be within the run_tests function within the KALiteTestRunner class.