Split server setup and run into separate functions for easier testing