add test, fix corner cases