Fixed tests and small bugs.