Resolve bug in the last_threads patch.

The last patch to ensure we always run the test->max_threads thread test
didn't work correctly because the "threads" variable was being incremented
in the last invocation of the for loop, and hence we couldn't tell if and
when the last test had /actually run/ or whether it was simply an incremented
loop counter.

This adds explicit tracking for the last thread number to run, so we can then
control what happens in case max_threads hasn't been invoked.