When starting or stopping a service is possible that the service was in process to start or to stop.
With this commit the process waits until the service reaches the required state.
Refactored 'wait_til_state' function to simplify it.
Made 'max_tries' configurable.
Made 'max_tries' configurable
Merge pull request #38 from alambike/wait_til_state

Wait to start or stop a service in corresponding action if it was in state of "STARTING" or "STOPPING"