add defer chain
add defer docs
change unittest for defer