Fix tests and refactor requires