More tests. Found a number of bugs.