One way you can quickly debug problems is by creating message boxes to show relevant data. For instance, in the code above, you can insert a line of code that prints the list of column names stored in the headers variable. Note that you need to call the standard JavaScript function toSource to serialize JavaScript Arrays. The resulting code will look like this:
var headers = headersRange.getValues()[0];
Browser.msgBox(headers.toSource());
return getObjects(range.getValues(), normalizeHeaders(headers));