Tests and improvement for #153