Fixed expiration bug

+ added tests