tests code refactored