split out server init, and handle errors

Signed-off-by: Niv Sardi <xaiki@evilgiggle.com>
Merge pull request #203 from inaes-tic/xaiki/fix-ugly-server.js

split out server init, and handle errors