Tidying code and tests