Skip looping across tasks in common case

When a run is finished (common case) there is no need
of looping across its tasks.

This greatly speeds up the build of the tests overview and
allows scalability to big number of tests.

WARNING: I have modified the DB to add run['finished'] field
to all the entries !!!!