Add more unit tests
Code cleanup