fixed testing for collapseDuplicates