Checking for isDeclaredSingleton fixes the problem with vars. But then, last change along with this one break tests.