short-circuit during sample generation to avoid stack overflow when
working with self-referencing classes
Added assert for count of elements in the collection to unit tests