Adding buffer and fixing unit tests