* updated according to code review.
* added test case for insert failure