Add low level functions
To allow better control over memory added low level functions that require the caller to provide the needed buffers. The high level will allocate those with an arbitrary and then shrink them. They will always work since they will loop until the buffer is large enough. In the low level versions all that is the responsibility of the caller.
Added tests.