Fixed test failure and improved post_delete_layer logic.

My last commit failed one of the test cases this fixes the issue.  My apologies.