On Fibonacci and Lucas sequences modulo a prime and primality testing