Improve LCOV reporter and fix bug when toHTML set to false

Similar to (if not identical to) #402, #403, #391 but asking for merge into develop instead of master.

Aside from fixing the issue with the lcov data not being appended to the global variable, I've also improved some of the internal API slightly.