Rewrote Data.Store.Internal.Function (reduced code duplication, improved performance significantly). Added some tests.