added random shuffle to merging function; added test cases