fix _fmpz_cleanup to make repeated calls safe; add test code