Fixed default https port assignment, added tests.

Thanx to @sylvaingi for finding the bug.