Starting and closing server before while testing