added tests and fixed fillbuffer funciton