Fix url generation in functional and acceptance tests

Fix for #4608

Also can fix other issues with a port lack in a absolute url.