Fix scoping issues in rest steps