for loops fixed, tests introduced