Refactor tests #4583