add test and some changes