Cleanup code and fix uninitialised variable issue

- fix indentation
- fixes uninitialised value warning
- cleanup code
- use CAF for testing