Set retry envelope only when status changes

also added some envelope tests (issue #6)