Refactor loops so that condition can be evaluated asap, close #1105
Merge pull request #1113 from excilys/loops-refactoring

Refactor loops so that condition can be evaluated asap, close #1105