better prime testing algorithm