Adding some UT and solve some bug