When simple dependency inversion does not give full flexibility, the abstract factory pattern may prove to be useful. At least it allowed me to keep my single threaded persistence fake for testing in an environment that otherwise required multithreaded transactions... and this is how...