Thread the server object

Instead of the server being the main process allow it to be threaded
to make testing and importing easier.

Change-Id: I5950b29188ed41a280f467f06bb4d3eb1f65b12a