Fix bug in doc building script. Tweaks related to tests.