Fix various integration tests

See detailed description in each individual commit for more info.
Could use `Preconditions` with `checkNotNull(val, msg)` and `checkArgument(val instanceof Integer, msg)` here?