I find the 'never fix a bug and refactor in the same commit' advice somewhat questionable.
If the code is a mess and I'm going to refactor it anyway should I spend a lot of time trying to fix the bug in the old code only to refactor it afterwards? Or should I refactor and deliberately leave the bug in there only to fix it afterwards?
To me doing them together often makes sense and I don't remember code reviewers ever complaining. But maybe I'm missing something?