Add test for factory throwing an exception