fix selecting a stock port and add regression test

Tiny branch that fixes a regression in the stock port selection. Plus regression test.