Yes, you're right. I made a mistake when marking the wrong nodes. I should left the last node of the wrong path unmarked because it could be the node in the actual loop, which is exactly what goes wrong in your test case. Since it couldn't be the case that a certain wrong path contains more that 1 nodes that are in the right loop, it should be right after correctness. Thanks for your advice!
Yes it's a loop, however the problem statement ask to have loop in one direction only, so if you started the loop moving forward you can't move backward, and vice versa. So in your question you are moving 0 -> 2 -> 3 which is forward then 1 -> 0 which is backward