Changed how root is initialized.
Fixed a leak in the test code.  The factory is now explicitly released after the test.