Fix port allocating helper function.
Add a basic http authentication test.