Start to add unit tests for the geometry re-assembly code
Also, fix handling of the closing edge of polygons.