Fix hasOwnProperty and add tests