API tests: fix file handle leak in SBT, thread exhaustion in Travis

I believe I finally have a handle on the multiple problems, and have fixed or worked around them here. What a pain.
Right, which means mocking HTTP request and response objects. For all I know, that might be easier than what I've been through already.