Added CopyBuffer() method and unittest for it