Split HTML and table serialization routines into separate modules
Fix test.lua and clean up code