Fix address in use issue when running tests

Correctly stop servers allowing integration and functional tests to be
run together.