No longer sets 0 directly, instead uses custom  global, and freezes returned structs.
Added tests for wait3 and wait4.