Fixed tests and detected bugs.