update CachingIterator class
add unit test for CachingIterator class