D map builder restructure file

Addressed previous commit comments:

* Included check for tmp file creation
* Instead of pre-loading values, they are retrieved from file for each key
* Fixed broken test
* Also added two more tests:
     - Duplicate key insertion scenario
     - Sorted entries in block