Refactor the for in hack to use Object.keys instead

A for in with an imediate break was used to retrieve the first key of an
object. We now use Object.keys