Add a download function and tests (some lint fixes snuck in)