added undefined check in iterator test