Code cleanup: use QMutexLocker in InputOutputPatch
Fix unit test so that it doesn't leave changed files after it is run.

The file is copied from template and the manipulated. The copy is ignored by git.