Add unit tests, fix incorrect class instanciation