Add unit test for Location.

This adds a randomized unit test for Location, covering general behaviour as well as the corner case fixed in the recent Location rewrite.