Fixed metadata logic and test.