More tests. Fix bugs.