made tests, fixed bugs