Fixed the key gen methods to use bouncycastle and generate keys properly. Added supporting unit tests too.