Add test for $var ranging, also improve process_code