TRUNK-3569: Unit tests added

https://tickets.openmrs.org/browse/TRUNK-3569

previous merge : https://github.com/openmrs/openmrs-core/commit/2c7079443ad4b9fa7d7944289b4a0e30eee4f8f0