refactored rendering and added helper test for render_markdown