fix iterator

- fix bug caused by bad iterator from work on #1
- add iterator tests