fixed each() and related test cases