starting to use unit tests, already improved metadata reading algorithm