Fix from kostko's fork, commit 32a224ff639ea71b44ceb3750d0e3fe85b216f83
Bugfix in test_delivery