Implement unittests for HTTP test helpers.

Fix some bugs found in unittesting.