more tests, some bugfixing
more functions covered by tests