couple otimizations to the Miller-Rabin algorithm