Improved estimateSegments() heuristic and fix tests