Develop main function

* Write unit tests for main function
* Complete main function