Fix keypair generation, and certain edgecases in decryption.

 * Now this tests keypair generation against the test vectors.
 * Found another bug in the Java reference code.
 * This should work as intended now.