added free function to avoid windows debug/release free mismatch, fixed issue with buffer size
added proper tests