Add a proper namespace check and also a unittest for an improper namespace.
Now that namespacing is checked, there is no need for further testing in the
to_dict method.