each

Added each loops and test logic.
Extracted length logic.