Fix #50 - Missing time import.

Also added tests and made a minor modification to Key.to_protobuf().

This fixes #50.