Should check if attribute exists in order to throw Error

When a DOM element does not have an id it returns an empty string instead of undefined.

Related to https://github.com/eduardolundgren/senna/commit/534004fc37ed5981fe3ffd89fdd9b3aac91cd603#commitcomment-7767287
Multiple vars is used in this project even though we are aware of potential hoisting problems.