Issue #1327 regression test and fix

Hi Travis, I came up with a regression test and a fix, please merge or cherry-pick.

Why cast to boolean here?