Improved method for finding reference files from header, added test for function