handle some corner cases in EMULATE_FUNCTION_POINTER_CASTS, and add testing