Add test and minor tidying