@dreid recommended changes and tests added