Fix resourceSet(). Previous implementation didn't walk correctly through existing data

- Add unit test accordingly;