Handle http errors correctly, fixes #20