misc fixes and tests