Fix regression in setProperties

The switch to Object.keys caused a regression because `for x in y` works for non-objects as well. All credit to @stefanpenner