refactor some tests to simplify the code