Improve tests and code.