Splitted code into modules. Re-factored tests