Bugfixing, added new tests