Detached the downloading logic in another class and added tests for it.