Fixes issue #834

Rewrite wait_for_upload_id function so UploadCancelledError is raised
when state is _CANCELLED, previous logic didn't raise UploadCancelledError
if upload_id was set.