More locally_refine fixes

Infinite loop fixed, and we now interpret -1 as 0 rather than
uint(-1).
Add locally_refine_regression.sh test