Refine Test Algorithm