Use limit() instead of capacity()

Change wrappedBuffer(ByteBuffer) to use limit() instead of capacity().