Pull changes to fix getlantern/lantern#1895

Pull changes to fix getlantern/lantern#1895
@myleshorton Here is the unit test that I should have had in the first place.