more documentation, tests and bug fixes