fix BUG to call res.end() before res.write(chunk) for last chunk by wrong process.nextTick()
fix code styles