Added more tests and implementet better handling for buffer_size