add lock with diag
 make params into unittest