Fix most specs and improve the testing environment

This is in a pending spec, so I guess it's OK.