Set 'type' property first. Fixes #3

A simple fix. Test passes in Opera (and Chrome and Firefox and IE9).