New version fully working, tests included