Fix getUsedStoreValues and allow a range to be passed

Also add unit tests to prove it works now.

Change-Id: I94e72c0a5cd2b57c4a4ad33af94d8e8afffd9a62
Merge "Fix getUsedStoreValues and allow a range to be passed"