Refactor call_scan and add tests

https://bugzilla.redhat.com/show_bug.cgi?id=1114063
Refactor coding style

https://bugzilla.redhat.com/show_bug.cgi?id=1114063