Reorganize helper functions in test/run.js.