Add some tests
Code cleanup