Fix NRE in tests