Set up a very basic test infrastructure. Corrected some bugs.