Replace falsy checks with safer `undefined` checks

Also add test with `0` value.