fix sporadic errors with unit tests