Added ability to replace Singleton instance with custom object in tests.