Refined unit test and cs code.