Prepare migrating testing auxiliary functions from tests to testutil. Remove local duplicates on testutil.WriteToNewTempFile(). Always favor testutil.NewTestCaseDir() over ioutil.TempDir(). Add test cases for the testing auxiliary functions.