Fix bug found by @andershedstrom.

Was able to test the fix by modifying an existing test case.