refine the code about test threshold.