More tests and more fixes