fix logical error that made the unittests crash