Clean up whitespace.
Substantially more comprehensive unit tests.

Check all the interesting implementation details in metadatavalues
which were never tested before, as well as making sure we document
things thoroughly.