Okay, unittests mostly fixed.

- So the getmetadata API documentation appears out of date in that I can't get it to work, so that test fails.
- I need remove all unused code.
- I need to do documentation, but for the moment a developer could look at the unittests to get a general idea of how to use it.
- I need to refactor some things to make it a bit more elegant.