Refactor resource test, and introduce a base class