Primality tests, linear recurrent sequences and the Pell equation