Fix a BIP32 public key derivation bug.

Fixed a bug preventing from BIP32 public key derivation from always
working. Also added C++ unit tests for said derivations.