Service

1. Refactor the findPort function: clearly separate the finding logic for int type and string type

2. Refactor the findPort test: use table driven test approach

if StrVal = "", you're now going to spend time looking for it, when you know it doesn't exist.  Actually, worse, you're going to hit on the first port that doesn't have a name (name is optional).

I think you need to short-circuit if kind = string && StrVal == "" && first == -1