Fixed iterators and added tests