fix iterator bug and add initial tests