Fixed an issue handling metadata when it is a string. Added additional test cases for full code coverage.