updated tests according to loops and when