add testing and code fixes

@jwolski @mranney 

if curious, i'll pull myself by AM.