Test for cycle detection