Added main and test functions