Fixed version error and test
Tidy up code