added code and test to db_iterator