Add more test and fixed some small issues