Add more test and some minor improvements