Fix crash caused in non-test mode caused by extracting diff function