changed implementation for NSData, updated tests