merge files - function and test