Refactorize tests