Modified tests and bugfixes