refactored into a celery task.
added tests