Fix an error message broken by earlier debugging, and also fix long-standing shutdown problems. Move basic tests to more standard location.