refactoring test code to be more simple and readable