Fix twist

Fix the twist command, and add a test.