Refactor GMP prime test