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

@thockin The returned invalid port value is -1. So I was trying to follow that conversion. Do you suggest me to change it to 0? I am also happy to that.