Avoid using hard-coded ports which could break tests on the CI-Server and better benefit from the IOHelper#close() utility.
Should still support Java 6 as well.