bug and test fixes