Add test case for factory method