new test for structureFromItem, fix a whole slew of bugs discovered by the test