add test + fix some minor error