If the configuration is injected in the factory, this can be moved into a discrete method instead of implemented as a closure. That will also make the functionality easier to test.