Add some testing for fallback, some testing that media-level-only

atrtibutes in the session level are properly ignored (both during
parse, and by HasAttribute). Fixing bugs uncovered by these tests.
This kind of memory leak protection (i.e., "if you're about to overwrite a non-null pointer, how about you free the thing you're about to leak") really belongs in SetAttribute, not here.