I suspect the intent of this test was to verify that httpapi really doesn't bind to that port. That HttpAddUrlToUrlGroup() fails implies this, but paranoia in a case like this is rarely unwarranted.
However, this test cannot reliably succeed; some other operating system component may open a TCP port in the meantime, and it appears that on Windows 10 this does in fact happen.
Since the goal of the test is just extra paranoia, I don't think it's worth keeping.