Florian,
Nice job! After applying the patch, it passes all tests for me. Perhaps I'll run the patched version for my students.
I was considering tackling the pattern-matching myself, but I'm glad I didn't, because you've done it much more quickly than I could have. Instead maybe I'll study your solution and write some more tests. :)
Dana