This is not the way to write XSLT:
XSLT is a language for transforming input trees into result trees. The result tree is then (optionally) sent to a serializer to be turned into serial XML. Very occasionally you need to prod the serializer to do something unusual, and that is the only time you should use disable-output-escaping. What you are trying to do here is to bend XSLT into a language for writing textual XML, in the form of tags, and you are getting yourself into a mess as a result.
Writing a node to a tree is an atomic action, achieved using a literal result element if it's name is known statically, or xsl:element if not. You don't write one half of the node at one time, and the other half later.
To write a table with data items arranged four per row, your logic should look like this:
for each group of four items
for each of the four items
output the item
<xsl:for-each select="Course[position() mod 4 = 1]">
<xsl:for-each select=".|following-sibling::Course[position() < 4]">
Sorry not to help you with your immediate problem, but this code is no place to start from.
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference