added miller-rabin test, and better random routines