Improve test coverage, fix issue with toLine and toPolygon