beautify code in atom
fix stream error catch, add test