Set namespaces of attributes correctly

Also added tests for them.

I'm not sure what happens to prefixed elements, but that's all the info I could find in the parser output format for now.
Nit: cap at 120 chars