Make Document::[un]register_named_element take Atom by reference.

This is follow up for 628191e372bc85cf3700e9e15c25042a77e5ff01.

Fix #3444