a few small fixes and additional tests
oops, commented self-test