CRM-15236 fix bugs in reports & extend testing

The original PR went stale & since it was 'cold' I decided to just retrieve the stuff that re-applied cleanly & push into master