raise HasCycle when detect referces list has cycle
added test for HasCycle