Handle duplicate attributes

This fixes a bug where the last attribute encountered overwrites all
others attributes having the same name.

Added test file.