Stability/integrity improvements

Implements fixes for issues #3, #4, and #2.
Could you also write a simple test in rspec to check if the server shut's down correctly?