Fix reversed logic and update test to include an assert.