Fix references
Make sure to avoid NRE in tests