consolidate pk, pubkey functions; ensure the secret exponent is a valid number; improve unit test organization