misc fixes + tests