Add test for gracefully handling write failure