Fix the factory to return a function that returns xhr objects