What you want is simply impossible to do in C: your testfunct uses a "return lua_yield(...)" (basically a trailing call that a C compiler may eventually optimize into a jump in some platform-specific conditions, but not always like in Lua). That lua_yield() calls is still in C, and the C stack pointer will return to the point where this call was done, i.e. still inside the "testunct" function where it will return (an optimizing compiler may eventually have resolved it as a jump (after popping the current stack frame of "testfunc" and repolacing it with the stack frame for "lua_yeild" just before dong the jump. The return address of the "testunction()" call is still in the C stack and not modified, but it points to the instruction AFTER the call to testfunc; there's no way to restart the function from the beginning, simply because there's no warranty that the stackframe inside the function "testfunc" is still there and valid (it may have already been destroyed and replaced by the stackframe for lua_yield(...).
Yielding coroutines is not supposed to perform such loop implicitly (and tricking the Lua VM will not help you) : you have to write the loop explicitly yourself in C, around the call to lua_yield() inside the "testfunct" function, in order to allow it to loop, and use a continuation condition for your loop, that may depend on the value returned by lua_yield(), i.e. the value passed by the coroutine.resume(value), or on the value of an external variable...
Coroutines are just pausing and always resuming **after** at the point where they yielded, but **never before that point**.