added heap struct, unit tests and fixes