General bugfixes. Cleanup in testsuite, especially with docstrings.