moving logic to library and adding specs
moving download logic to library