Added unit test for multi-ref files and fixed a bug the test revealed