updated
added MemoryInputStream
added tests
fixed bug