Fixes to curl function and tests