Fix exiting namespace when it's the last child (#223), clean up surrounding code
Merge pull request #228 from oneeman/fix-exiting-namespace

Fix exiting namespace when it's the last child (#223)
Fix test failures on Internet Explorer (#229)

-- Convert value for setAttribute() to string
-- Make repairClonedNode() safe to call on uncloned nodes (e.g. first rendering)