Fixed tests and tidy up