SERVER-10298 SERVER-10277: add tests and cleanup code to match for update replacements