Minor cleanup: move helpers out of _onChunk

Change-Id: Id7cf151912bc9d60f0931b7c7a3d2a742130a0d7