Fix some out-of-order checks in the tests.

We shouldn't index into the outbox before checking the length of it. This
normally isn't a problem, but it can be in the case that other tests aren't
torn down properly.

Testing done: Ran unit tests.
Merge branch 'release-2.0.x'