Improve tests and docs