Refactored controller and unit tests

added unit tests, test for 2 results still fails but I don't know what's
wrong with data