test fixes and refactor
test fixes