Fix test and refactor.