Final version with some tests