* Only remove attributes when the tag is a metadata tag. * Add tests. (cherry picked from commit 3b581af6)