Emitting events on error and done
Fixed tests