Fix random failure in units unit tests

An attempt to fix the occasional failure since #1289.