Decouple html creation from models into helpers
This is a work started by @joenio and continued by @danielafeitosa for which I have just fixed failling tests and some minor issues created by the refactor.
This MR adds just the fixes that do not involve plugins. As I've discussed with @diguliu there ill be separate MRs for plugins allowing easier review e clean merges.