Fix GMP tests/crashes

This should fix some crashes and all bad tests other than 014, and 028.

I marked test 014 as it is checking for wrong return values due to a bug in PHP.  It appears as those PHP is using the resource number as the factorial rather than the resources value, giving unpridictable results.

Test 028 still fails as gmp_random is not implemented.