Refactoring meta-data test code. Part of #1843.