First unit tests. Fix first bugs.