Iterating more smarterly.
Fixed test function.