Fix NPE in tests