Added test for factory pattern