Bugfixes + add more tests