Write tests and fix some typo