Clean up code to be more testable. Add test cases for named and numeric ports in TCP health checks. Improve tests.