Bugfixing and more tests