Add error-handling tests for factory module