Improve cleanup in case of initialization failure.
used the default port. He was right. I fixed the problem and added the test cases 521, 522 and 523 to verify the fix.