Add null check to avoid crash in unit tests that use mock singletons.