race conditions fixes

This pull requests fixes race conditions in tests and listener (I've recently created issues in the main repository).
How did you make the server to no longer exit gracefully?

Btw, there's another race condition between ```server.ListenAndServe``` and ```http.Get```.