Fix tests, improve documentation