add a test, fix a bug