Add unit/integration tests on main functions

- Re-add hunit tests.
- Fixed 2 subtle bugs that composed together cancelled themselves.
  - the order of the scanned wifi was incorrect.
  - the order of the parameters in the elect call in the main function was reversed (due to implementation detail, this operation is not commutative. elect is based on Data.List.intersect)