cleanup attr parsing and fix a bug I introduced in the previous refactoring
In the previous refactor I used .ok(), but that throws away the error.
I then noticed that the code I used could be simplified with the parsers::parse util, but I did not like that it took the attribute as a string just to turn it back into Attribute, since it is always called from places where we have the Attribute itself. So I factored out a trait.