Primality testing and Jacobi sums