refactor tests code