Started implementing tests for runInstance method. Also did some refactoring.