checkasm: Enforce declare_func to be outside of check_func
Move the declaration of func_ref/func_new into declare_func. This enforces that declare_func is a scope outside of/before check_func.
This ensures that if the signal handler is triggered, we rewind to a scope outside of check_func, where check_func makes sure we don't rerun the test that just triggered the signal handler.