refactor, cleanup tests code