Fixed tests; refactoring Server