Check whether offset+count can be fulfilled by specified bytes.

Also add helper methods in Preconditions class for checking inputs to the public API.