Fix port detection bugs and add more ports for linux.
Only close serial port if not already closed.
Add another test to explicitly connect to a serial port.