Improve tests and documentation