test fixes and code unification