Refactor tests and request logic