Fix crash in the unit tests

fixes #7648