added cache tests and generalized a lot