Refactored gateway rulefile loading
Refactored rulefile loading in gateway. Added unit tests back following refactor.