updated UT and fix a condition