add test case and bugfix