Add caching support as written in orig code to theoretically fix assumptions in tests