Added test module for code coverage.

This exposed some bugs, which are now fixed.

To make library code more testable, HTTP response content types are now in main modules.