Fix NPE in unit tests