add basic unit tests and start to convert code to OOP