fix possibly infinite loops in tests (closes #139) Closes #139 See merge request szt-ab-2022/group-01/tree-o!97