rename static to staticDir to follow dataDir naming
split up mainServer() into smaller, more testible funcs