Fixed bug in retrieveRecords that was causing tests tp hang