Fix crash in tests