Improved performance

Replaced StaticBufferedInputStream and ByteArrayInputStream
by implementations that are not thread-safe
Fixed unit tests