Celebration and caution as Galloway wins by-election