Refactor patching tests