Tidy up code and test docs