fixed tests by improving logic