This fixes #7970.
The tests for bug #7970.
This fixes #7934.  It now correctly creates the list of ports.