Server refactoring

I think this framework is awesome. I made some refactorings while I was trying to understand the code. Basically I moved the HTML generation from server.py into its own module and wrote the first tests for this part of the code.

The examples worked on my machines and the tests pass.