add cycle check + fix reference name test