add UnitTest to methods and fix some bugs