Add test code for checking delivery status and bounce reason
Improved code for setting delivery status