Fixed the bug in Enumerate

Added the relevant unit test as well.