Use `hasOwnProperty` instead of `undefined`. Add tests for use case.