Add some unit tests
Little refactoring