Bugfixes
Including some tests