Refactor metadata specs

This is a prepatory step for #1231.  Refactoring the metadata implementation will be much easier with the specs not directly calling internal APIs like `process` and `for_example`.