Tests, minor bug-fixes