Refactor resource and add unit specs