prepare_latest fix

In case if one of prepare_latest's groups is not presented in
state's list prepare_latest throws an exception. This fix adds try
catch statement to catch the exception and returns appropriate
error code
Merge pull request #324 from euroelessar/lts

prepare_latest fix