Refactor endpoints test