Fix server executable entrypoint

Also, split the server entrypoint in one method for tests with
debugging enabled, and one for the executable, without debugging
Protect against undefined election