Refactor tests and code.