Fix the algorithm in Trial Primality Test