Fixed possible indexoutofbounds error when adding an empty list as a response

Also updated test to run this situation.