test on Entity\Collection.
refactored to use exists method for checking duplicates.