Versioning expire function tests

Added some tests to the expire function and fixed some small problems. The fixes might also fix #6729 

cc @PVince81