oops, fixed bug introduced by last change, added test case