assert that output length matches expected length

also probably best to put this code into a reusable method since you use it in other places