factory pattern implemented, unit test added