If there were merged vertices, sometimes the output faces had wrong vertex indices. Added a test for this, and fixed.