refactored grid_ref_array method, tidied up tests a bit