Correctly evaluate the test kwarg when running a state.

Resolves #7788.