Fixed get_metadata and added tests.