Fix a bug for small inputs in prime test.