added test for getMetadata method and fixed bug