Add more tests; fix hangs and recovery issues.