Fix failing tests.

First complete and working version.