BS-11065 : Refactor code to reduce the complexity

- Add unit tests for ProcessInstanceServiceImpl & refactor it
- Refactor ActivityInstanceService