contactsTable.setHTML(table.getInnerHTML());
should read as follows.
contactsTable.setHTML("<table>" + table.getInnerHTML() + "</table>");
The problem is that getInnerHTML( ) gets the HTML inside the <table> ... </table> tags but does not return those tags themselves.