fix bug of server error do not send mail to admins
partial pass unit test. TODO: still two failed