added some error catching to class2tree fxn, and a test for it, closes #240