invoke callback after we're sure all writes are complete

plus misc. 

this should fix the intermittent travis failure.