Fix milestone selection code.

We can't just pick the last numbered milestone in the list, because
sometimes the milestone for the next iteration will be there before that
iteration has started.