Added number of unit tests for rmt calls. Fixed couple bugs found in db calls