improve iteration and fix some broken tests