inverse bag

fixes #20
also add tests