Raz: Some more code refactoring. Fixed some more synchronization bugs. Added some general server tests.