add test and bugfix