Add a test for 'toHierarchy' method.