add test, fix minor bug