add auto-port logic + simple test