Rename type() to getType().

- Oops.
Rename methods and add comments.

- Syncing with latest unit test "styling".
Add null checks on various methods.
Add unit test for KeyVersionRegistry.