More tests and performance optimisations