Fixed the patchfile tests and tidy up the patchfile backends.