refactor metadata registry and add tests. Inject metadata registry into objecthydrator