Refactor the exact_match fix, add basic test for it