Fixed #16 and #17
Refactored shutdown routine for Application Containers and Application Master
Added tests to simulate various error conditions