Dolphins end losing streak with hard-fought Rams win