fixed handling of nondefault gateway ports.

some code cleaning
clean log cache after creating and checking out branch
adapted test suite, so it can be run with setup tools