   objectValue = object[objectKey]
   objectValue = JSON.stringify(objectValue) # match in stringified arrays and objects too
   re = RegExp testValue, "im"
-  match = objectValue.match re
-  return if match then true else false
+  match = re.test objectValue
+  return match
 
 # "And" the results of multiple tests
 andTest = (object, tests) ->


# Check if specific field value is empty
isEmpty = (objectKey, emptyTest, object) ->
  objectValue = object[objectKey]
  shouldBeEmpty = emptyTest['empty']

  if shouldBeEmpty #return true if objectValue is empty
    return objectValue.length is 0

  else if not shouldBeEmpty #return true if objectValue is not empty
    return objectValue.length isnt 0

# Check if the test is a pubdate test
isPubdateTest = (testValues) ->

# Extract specific time from the document pubdate field and compare it with the test
matchesPubdate = (objectKey, pubdateTest, object) ->
  objectValue = object[objectKey]
  year = new Date(objectValue).getFullYear() # convert to milliseconds

  if 'year' of pubdateTest # compare years
    testValue = pubdateTest['year']
