compatibility with Dancer 2

Here's the amazingly extensive patch required to make all tests pass under Dancer2. :-)