test fixes and some minor bugs