Add more tests
Move functions to own package