refactor code UnitTest