Fixing a NPE error found by tests.