Fixed bugs in derivatives.  Oh my goodness, how did these get coded?!

Fixes #3787

Some tests needed re-golding to fix minor discrepancies.
Merge pull request #3788 from WilkAndy/mc_deriv_3787

Fixed bug in derivative.  Fixes #3787