Added iterate and iterateSync functions and tests for them