fixed maxitem bug in iterators, added unit tests for sums
fix in tail tests