Changed limit to 400 for download API.
Minor bug fix to test_api.py, and set the output file buffer to flush to disk after every query so results are not lost in the event of power failure.