Fix iterator bug and add test of cargo, iterator