Metadata unit tests

Added several unit tests for metadata item creation. Finally possible after a few rounds of refactors.