Extract test functionality

Fix #101.
alternatively, we could make the arguments accept `null` to unset the port etc. that would remove the need for the `if` and could allow to revert things in special situations. i don't like the config array more than the ifs.