#57: improved tests, found and fixed bugs