Add testing infrastructure and fix broken tests