Re-implement `testPrimeInteger` predicate (#9281)