simplify and clean up test code