Fix GMP tests/crashes

This should fix some crashes and all bad tests other than 014, and 028.

I marked test 014 as flakey, as it is checking for wrong return values due to a bug in PHP.  It appears as though PHP is using the resource number as the factorial rather than the resource's value, giving unpridictable results (depends on how many resources have been used thus far)

Test 028 still fails as gmp_random is not implemented.