factoring out for tests

tests will come later since there is a bug on the metadata