Adding filtering
Tidying up tests and the cacheing code