refactored CollectionBuilder and added CollectionBuilderTest.