Fix clashes between debugger tests and coverage.py

coverage.py works by setting the trace function. But so does the debugger, so we need to re-set it after testing the debugger to get accurate coverage results.

I noticed a disparity between the coverage numbers for Python 2 and 3, which seems to be down to the order in which tests are executed. Hopefully this will fix it.