Move stuff out of list_command to api so it can be reused

This is for Michal as we want to dispatch the requests also during the checking