Bugs in tests corrected and docs updated