Ensure replace always commutes with test and replace.