killbill-aplcache

account: expose fixed offset timezone and reference time These

2/15/2016 8:20:05 PM

Changes

usage/pom.xml 5(+5 -0)

Details

diff --git a/account/src/main/java/org/killbill/billing/account/api/DefaultAccount.java b/account/src/main/java/org/killbill/billing/account/api/DefaultAccount.java
index 957b2e2..3aff5c5 100644
--- a/account/src/main/java/org/killbill/billing/account/api/DefaultAccount.java
+++ b/account/src/main/java/org/killbill/billing/account/api/DefaultAccount.java
@@ -1,7 +1,7 @@
 /*
  * Copyright 2010-2013 Ning, Inc.
- * Copyright 2014-2015 Groupon, Inc
- * Copyright 2014-2015 The Billing Project, LLC
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
  *
  * The Billing Project licenses this file to you under the Apache License, version 2.0
  * (the "License"); you may not use this file except in compliance with the
@@ -27,6 +27,7 @@ import org.joda.time.DateTimeZone;
 import org.killbill.billing.account.dao.AccountModelDao;
 import org.killbill.billing.catalog.api.Currency;
 import org.killbill.billing.entity.EntityBase;
+import org.killbill.billing.util.account.AccountDateTimeUtils;
 
 import static org.killbill.billing.account.api.DefaultMutableAccountData.DEFAULT_BILLING_CYCLE_DAY_LOCAL;
 
@@ -344,6 +345,16 @@ public class DefaultAccount extends EntityBase implements Account {
     }
 
     @Override
+    public DateTimeZone getFixedOffsetTimeZone() {
+        return AccountDateTimeUtils.getFixedOffsetTimeZone(this);
+    }
+
+    @Override
+    public DateTime getReferenceTime() {
+        return AccountDateTimeUtils.getReferenceDateTime(this);
+    }
+
+    @Override
     public String toString() {
         return "DefaultAccount [externalKey=" + externalKey +
                ", email=" + email +
diff --git a/account/src/main/java/org/killbill/billing/account/api/DefaultImmutableAccountData.java b/account/src/main/java/org/killbill/billing/account/api/DefaultImmutableAccountData.java
index e1df215..ff850da 100644
--- a/account/src/main/java/org/killbill/billing/account/api/DefaultImmutableAccountData.java
+++ b/account/src/main/java/org/killbill/billing/account/api/DefaultImmutableAccountData.java
@@ -1,6 +1,6 @@
 /*
- * Copyright 2014-2015 Groupon, Inc
- * Copyright 2014-2015 The Billing Project, LLC
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
  *
  * The Billing Project licenses this file to you under the Apache License, version 2.0
  * (the "License"); you may not use this file except in compliance with the
@@ -19,8 +19,10 @@ package org.killbill.billing.account.api;
 
 import java.util.UUID;
 
+import org.joda.time.DateTime;
 import org.joda.time.DateTimeZone;
 import org.killbill.billing.catalog.api.Currency;
+import org.killbill.billing.util.account.AccountDateTimeUtils;
 
 public class DefaultImmutableAccountData implements ImmutableAccountData {
 
@@ -28,16 +30,20 @@ public class DefaultImmutableAccountData implements ImmutableAccountData {
     private final String externalKey;
     private final Currency currency;
     private final DateTimeZone dateTimeZone;
+    private final DateTimeZone fixedOffsetDateTimeZone;
+    private final DateTime referenceTime;
 
-    public DefaultImmutableAccountData(final UUID id, final String externalKey, final Currency currency, final DateTimeZone dateTimeZone) {
+    public DefaultImmutableAccountData(final UUID id, final String externalKey, final Currency currency, final DateTimeZone dateTimeZone, final DateTimeZone fixedOffsetDateTimeZone, final DateTime referenceTime) {
         this.id = id;
         this.externalKey = externalKey;
         this.currency = currency;
         this.dateTimeZone = dateTimeZone;
+        this.fixedOffsetDateTimeZone = fixedOffsetDateTimeZone;
+        this.referenceTime = referenceTime;
     }
 
     public DefaultImmutableAccountData(final Account account) {
-        this(account.getId(), account.getExternalKey(), account.getCurrency(), account.getTimeZone());
+        this(account.getId(), account.getExternalKey(), account.getCurrency(), account.getTimeZone(), AccountDateTimeUtils.getFixedOffsetTimeZone(account), AccountDateTimeUtils.getReferenceDateTime(account));
     }
 
     @Override
@@ -59,4 +65,67 @@ public class DefaultImmutableAccountData implements ImmutableAccountData {
     public DateTimeZone getTimeZone() {
         return dateTimeZone;
     }
+
+    @Override
+    public DateTimeZone getFixedOffsetTimeZone() {
+        return fixedOffsetDateTimeZone;
+    }
+
+    @Override
+    public DateTime getReferenceTime() {
+        return referenceTime;
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder("DefaultImmutableAccountData{");
+        sb.append("id=").append(id);
+        sb.append(", externalKey='").append(externalKey).append('\'');
+        sb.append(", currency=").append(currency);
+        sb.append(", dateTimeZone=").append(dateTimeZone);
+        sb.append(", fixedOffsetDateTimeZone=").append(fixedOffsetDateTimeZone);
+        sb.append(", referenceTime=").append(referenceTime);
+        sb.append('}');
+        return sb.toString();
+    }
+
+    @Override
+    public boolean equals(final Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        final DefaultImmutableAccountData that = (DefaultImmutableAccountData) o;
+
+        if (id != null ? !id.equals(that.id) : that.id != null) {
+            return false;
+        }
+        if (externalKey != null ? !externalKey.equals(that.externalKey) : that.externalKey != null) {
+            return false;
+        }
+        if (currency != that.currency) {
+            return false;
+        }
+        if (dateTimeZone != null ? !dateTimeZone.equals(that.dateTimeZone) : that.dateTimeZone != null) {
+            return false;
+        }
+        if (fixedOffsetDateTimeZone != null ? !fixedOffsetDateTimeZone.equals(that.fixedOffsetDateTimeZone) : that.fixedOffsetDateTimeZone != null) {
+            return false;
+        }
+        return referenceTime != null ? referenceTime.compareTo(that.referenceTime) == 0 : that.referenceTime == null;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = id != null ? id.hashCode() : 0;
+        result = 31 * result + (externalKey != null ? externalKey.hashCode() : 0);
+        result = 31 * result + (currency != null ? currency.hashCode() : 0);
+        result = 31 * result + (dateTimeZone != null ? dateTimeZone.hashCode() : 0);
+        result = 31 * result + (fixedOffsetDateTimeZone != null ? fixedOffsetDateTimeZone.hashCode() : 0);
+        result = 31 * result + (referenceTime != null ? referenceTime.hashCode() : 0);
+        return result;
+    }
 }
diff --git a/account/src/test/java/org/killbill/billing/account/AccountTestSuiteWithEmbeddedDB.java b/account/src/test/java/org/killbill/billing/account/AccountTestSuiteWithEmbeddedDB.java
index 88bcf6b..1e146a5 100644
--- a/account/src/test/java/org/killbill/billing/account/AccountTestSuiteWithEmbeddedDB.java
+++ b/account/src/test/java/org/killbill/billing/account/AccountTestSuiteWithEmbeddedDB.java
@@ -1,7 +1,9 @@
 /*
  * Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
  *
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
  * (the "License"); you may not use this file except in compliance with the
  * License.  You may obtain a copy of the License at:
  *
@@ -16,21 +18,13 @@
 
 package org.killbill.billing.account;
 
-import org.killbill.billing.ObjectType;
+import org.killbill.billing.GuicyKillbillTestSuiteWithEmbeddedDB;
 import org.killbill.billing.account.api.Account;
 import org.killbill.billing.account.api.AccountApiException;
 import org.killbill.billing.account.api.AccountData;
-import org.killbill.billing.util.cache.Cachable.CacheType;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-
-import org.killbill.billing.GuicyKillbillTestSuiteWithEmbeddedDB;
 import org.killbill.billing.account.api.AccountUserApi;
 import org.killbill.billing.account.dao.AccountDao;
 import org.killbill.billing.account.glue.TestAccountModuleWithEmbeddedDB;
-import org.killbill.bus.api.PersistentBus;
-import org.killbill.clock.Clock;
 import org.killbill.billing.util.audit.dao.AuditDao;
 import org.killbill.billing.util.cache.CacheControllerDispatcher;
 import org.killbill.billing.util.customfield.dao.CustomFieldDao;
@@ -38,6 +32,11 @@ import org.killbill.billing.util.dao.NonEntityDao;
 import org.killbill.billing.util.tag.api.user.TagEventBuilder;
 import org.killbill.billing.util.tag.dao.TagDao;
 import org.killbill.billing.util.tag.dao.TagDefinitionDao;
+import org.killbill.bus.api.PersistentBus;
+import org.killbill.clock.Clock;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
 
 import com.google.inject.Guice;
 import com.google.inject.Inject;
@@ -89,9 +88,7 @@ public abstract class AccountTestSuiteWithEmbeddedDB extends GuicyKillbillTestSu
     protected Account createAccount(final AccountData accountData) throws AccountApiException {
         final Account account = accountUserApi.createAccount(accountData, callContext);
 
-        final Long accountRecordId = nonEntityDao.retrieveRecordIdFromObject(account.getId(), ObjectType.ACCOUNT, controlCacheDispatcher.getCacheController(CacheType.RECORD_ID));
-        internalCallContext.setAccountRecordId(accountRecordId);
-        internalCallContext.setReferenceDateTimeZone(account.getTimeZone());
+        refreshCallContext(account.getId());
 
         return account;
     }
diff --git a/account/src/test/java/org/killbill/billing/account/dao/TestAccountDao.java b/account/src/test/java/org/killbill/billing/account/dao/TestAccountDao.java
index 1592f85..0e6b38e 100644
--- a/account/src/test/java/org/killbill/billing/account/dao/TestAccountDao.java
+++ b/account/src/test/java/org/killbill/billing/account/dao/TestAccountDao.java
@@ -33,8 +33,6 @@ import org.killbill.billing.account.api.DefaultAccount;
 import org.killbill.billing.account.api.DefaultAccountEmail;
 import org.killbill.billing.account.api.DefaultMutableAccountData;
 import org.killbill.billing.account.api.MutableAccountData;
-import org.killbill.billing.callcontext.InternalCallContext;
-import org.killbill.billing.callcontext.InternalTenantContext;
 import org.killbill.billing.mock.MockAccountBuilder;
 import org.killbill.billing.util.api.AuditLevel;
 import org.killbill.billing.util.api.CustomFieldApiException;
@@ -112,9 +110,7 @@ public class TestAccountDao extends AccountTestSuiteWithEmbeddedDB {
         // Special test to verify audits - they are handled a bit differently due to the account record id (see EntitySqlDaoWrapperInvocationHandler#insertAudits)
         final AccountModelDao account1 = createTestAccount();
         accountDao.create(account1, internalCallContext);
-        final Long account1RecordId = nonEntityDao.retrieveAccountRecordIdFromObject(account1.getId(), ObjectType.ACCOUNT, null);
-        internalCallContext.setAccountRecordId(account1RecordId);
-        internalCallContext.setReferenceDateTimeZone(account1.getTimeZone());
+        refreshCallContext(account1.getId());
 
         // Verify audits via account record id
         final DefaultAccountAuditLogs auditLogsForAccount1ViaAccountRecordId1 = auditDao.getAuditLogsForAccountRecordId(AuditLevel.FULL, internalCallContext);
@@ -127,16 +123,14 @@ public class TestAccountDao extends AccountTestSuiteWithEmbeddedDB {
 
         final AccountModelDao account2 = createTestAccount();
         accountDao.create(account2, internalCallContext);
-        final Long account2RecordId = nonEntityDao.retrieveAccountRecordIdFromObject(account2.getId(), ObjectType.ACCOUNT, null);
-        internalCallContext.setAccountRecordId(account2RecordId);
-        internalCallContext.setReferenceDateTimeZone(account2.getTimeZone());
+        refreshCallContext(account2.getId());
 
         // Verify audits via account record id
         final DefaultAccountAuditLogs auditLogsForAccount2ViaAccountRecordId = auditDao.getAuditLogsForAccountRecordId(AuditLevel.FULL, internalCallContext);
         Assert.assertEquals(auditLogsForAccount2ViaAccountRecordId.getAuditLogsForAccount().size(), 1);
         Assert.assertEquals(auditLogsForAccount2ViaAccountRecordId.getAuditLogsForAccount().get(0).getChangeType(), ChangeType.INSERT);
 
-        internalCallContext.setAccountRecordId(account1RecordId);
+        refreshCallContext(account1.getId());
         final DefaultAccountAuditLogs auditLogsForAccount1ViaAccountRecordId2 = auditDao.getAuditLogsForAccountRecordId(AuditLevel.FULL, internalCallContext);
         Assert.assertEquals(auditLogsForAccount1ViaAccountRecordId2.getAuditLogsForAccount().size(), 2);
         Assert.assertEquals(auditLogsForAccount1ViaAccountRecordId2.getAuditLogsForAccount().get(0).getChangeType(), ChangeType.INSERT);
diff --git a/api/src/main/java/org/killbill/billing/callcontext/InternalCallContext.java b/api/src/main/java/org/killbill/billing/callcontext/InternalCallContext.java
index dee6931..ca0cd0c 100644
--- a/api/src/main/java/org/killbill/billing/callcontext/InternalCallContext.java
+++ b/api/src/main/java/org/killbill/billing/callcontext/InternalCallContext.java
@@ -45,7 +45,8 @@ public class InternalCallContext extends InternalTenantContext {
 
     public InternalCallContext(final Long tenantRecordId,
                                @Nullable final Long accountRecordId,
-                               @Nullable final DateTimeZone referenceDateTimeZone,
+                               @Nullable final DateTimeZone fixedOffsetTimeZone,
+                               @Nullable final DateTime referenceDateTime,
                                final UUID userToken,
                                final String userName,
                                final CallOrigin callOrigin,
@@ -54,7 +55,7 @@ public class InternalCallContext extends InternalTenantContext {
                                final String comment,
                                final DateTime createdDate,
                                final DateTime updatedDate) {
-        super(tenantRecordId, accountRecordId, referenceDateTimeZone);
+        super(tenantRecordId, accountRecordId, fixedOffsetTimeZone, referenceDateTime);
         this.userToken = userToken;
         this.createdBy = userName;
         this.updatedBy = userName;
@@ -66,16 +67,34 @@ public class InternalCallContext extends InternalTenantContext {
         this.updatedDate = toUTCDateTime(updatedDate);
     }
 
-    public InternalCallContext(final Long tenantRecordId, final CallContext callContext) {
-        this(tenantRecordId, null, null, callContext.getUserToken(), callContext.getUserName(), callContext.getCallOrigin(),
-             callContext.getUserType(), callContext.getReasonCode(), callContext.getComments(), callContext.getCreatedDate(),
-             callContext.getUpdatedDate());
-    }
-
-    public InternalCallContext(final InternalCallContext context, final Long accountRecordId, final DateTimeZone referenceDateTimeZone) {
-        this(context.getTenantRecordId(), accountRecordId, referenceDateTimeZone, context.getUserToken(), context.getCreatedBy(), context.getCallOrigin(),
-             context.getContextUserType(), context.getReasonCode(), context.getComments(), context.getCreatedDate(),
-             context.getUpdatedDate());
+    public InternalCallContext(final Long tenantRecordId, final CallContext callContext, final DateTime utcNow) {
+        this(tenantRecordId,
+             null,
+             null,
+             null,
+             callContext.getUserToken(),
+             callContext.getUserName(),
+             callContext.getCallOrigin(),
+             callContext.getUserType(),
+             callContext.getReasonCode(),
+             callContext.getComments(),
+             utcNow,
+             utcNow);
+    }
+
+    public InternalCallContext(final InternalCallContext context, final Long accountRecordId, final DateTimeZone fixedOffsetTimeZone, final DateTime referenceDateTime, final DateTime utcNow) {
+        this(context.getTenantRecordId(),
+             accountRecordId,
+             fixedOffsetTimeZone,
+             referenceDateTime,
+             context.getUserToken(),
+             context.getCreatedBy(),
+             context.getCallOrigin(),
+             context.getContextUserType(),
+             context.getReasonCode(),
+             context.getComments(),
+             utcNow,
+             utcNow);
     }
 
     // TODO should not be needed if all services are using internal API
diff --git a/api/src/main/java/org/killbill/billing/callcontext/InternalTenantContext.java b/api/src/main/java/org/killbill/billing/callcontext/InternalTenantContext.java
index 003fb19..8880c72 100644
--- a/api/src/main/java/org/killbill/billing/callcontext/InternalTenantContext.java
+++ b/api/src/main/java/org/killbill/billing/callcontext/InternalTenantContext.java
@@ -22,6 +22,7 @@ import java.util.UUID;
 
 import javax.annotation.Nullable;
 
+import org.joda.time.DateTime;
 import org.joda.time.DateTimeZone;
 import org.killbill.billing.util.callcontext.TenantContext;
 
@@ -35,14 +36,15 @@ public class InternalTenantContext extends TimeAwareContext {
 
     public InternalTenantContext(final Long tenantRecordId,
                                  @Nullable final Long accountRecordId,
-                                 @Nullable final DateTimeZone referenceDateTimeZone) {
-        super(referenceDateTimeZone);
+                                 @Nullable final DateTimeZone fixedOffsetTimeZone,
+                                 @Nullable final DateTime referenceDateTime) {
+        super(fixedOffsetTimeZone, referenceDateTime);
         this.tenantRecordId = tenantRecordId;
         this.accountRecordId = accountRecordId;
     }
 
     public InternalTenantContext(final Long defaultTenantRecordId) {
-        this(defaultTenantRecordId, null, null);
+        this(defaultTenantRecordId, null, null, null);
     }
 
     public TenantContext toTenantContext(final UUID tenantId) {
diff --git a/api/src/main/java/org/killbill/billing/callcontext/TimeAwareContext.java b/api/src/main/java/org/killbill/billing/callcontext/TimeAwareContext.java
index b265a4b..015ed10 100644
--- a/api/src/main/java/org/killbill/billing/callcontext/TimeAwareContext.java
+++ b/api/src/main/java/org/killbill/billing/callcontext/TimeAwareContext.java
@@ -17,20 +17,21 @@
 
 package org.killbill.billing.callcontext;
 
-import java.util.Date;
+import javax.annotation.Nullable;
 
 import org.joda.time.DateTime;
 import org.joda.time.DateTimeZone;
 import org.joda.time.LocalDate;
 import org.joda.time.LocalTime;
 
-// TODO Cache the reference time and clock in the context
 public class TimeAwareContext {
 
-    private final DateTimeZone referenceDateTimeZone;
+    private final DateTimeZone fixedOffsetTimeZone;
+    private final LocalTime referenceTime;
 
-    public TimeAwareContext(final DateTimeZone referenceDateTimeZone) {
-        this.referenceDateTimeZone = referenceDateTimeZone;
+    public TimeAwareContext(@Nullable final DateTimeZone fixedOffsetTimeZone, @Nullable final DateTime referenceDateTime) {
+        this.fixedOffsetTimeZone = fixedOffsetTimeZone;
+        this.referenceTime = computeReferenceTime(referenceDateTime);
     }
 
     /// Generic functions
@@ -52,17 +53,13 @@ public class TimeAwareContext {
     public DateTime toUTCDateTime(final LocalDate localDate, final DateTime referenceDateTime) {
         validateContext();
 
-        final DateTimeZone normalizedAccountTimezone = getNormalizedAccountTimezone(referenceDateTime);
-
-        final LocalTime referenceLocalTime = toDateTime(referenceDateTime, normalizedAccountTimezone).toLocalTime();
-
         final DateTime targetDateTime = new DateTime(localDate.getYear(),
                                                      localDate.getMonthOfYear(),
                                                      localDate.getDayOfMonth(),
-                                                     referenceLocalTime.getHourOfDay(),
-                                                     referenceLocalTime.getMinuteOfHour(),
-                                                     referenceLocalTime.getSecondOfMinute(),
-                                                     normalizedAccountTimezone);
+                                                     getReferenceTime().getHourOfDay(),
+                                                     getReferenceTime().getMinuteOfHour(),
+                                                     getReferenceTime().getSecondOfMinute(),
+                                                     getFixedOffsetTimeZone());
 
         return toUTCDateTime(targetDateTime);
     }
@@ -71,28 +68,26 @@ public class TimeAwareContext {
     public LocalDate toLocalDate(final DateTime dateTime, final DateTime referenceDateTime) {
         validateContext();
 
-        final DateTimeZone normalizedAccountTimezone = getNormalizedAccountTimezone(referenceDateTime);
-        return new LocalDate(dateTime, normalizedAccountTimezone);
+        return new LocalDate(dateTime, getFixedOffsetTimeZone());
     }
 
-    private DateTimeZone getNormalizedAccountTimezone(final DateTime referenceDateTime) {
-        // Check if DST was in effect at the reference date time
-        final boolean shouldUseDST = !getReferenceDateTimeZone().isStandardOffset(referenceDateTime.getMillis());
-        if (shouldUseDST) {
-            return DateTimeZone.forOffsetMillis(getReferenceDateTimeZone().getOffset(referenceDateTime.getMillis()));
-        } else {
-            return DateTimeZone.forOffsetMillis(getReferenceDateTimeZone().getStandardOffset(referenceDateTime.getMillis()));
+    private void validateContext() {
+        if (getFixedOffsetTimeZone() == null || getReferenceTime() == null) {
+            throw new IllegalArgumentException(String.format("Context mis-configured: fixedOffsetTimeZone=%s, referenceTime=%s", getFixedOffsetTimeZone(), getReferenceTime()));
         }
     }
 
-    private void validateContext() {
-        if (getReferenceDateTimeZone() == null) {
-            throw new IllegalArgumentException(String.format("Context mis-configured: getReferenceDateTimeZone()=%s", getReferenceDateTimeZone()));
-        }
+    protected LocalTime computeReferenceTime(@Nullable final DateTime referenceTime) {
+        return referenceTime == null ? null : toDateTime(referenceTime, getFixedOffsetTimeZone()).toLocalTime();
     }
 
     // For convenience, to be overridden in tests
-    protected DateTimeZone getReferenceDateTimeZone() {
-        return referenceDateTimeZone;
+
+    public DateTimeZone getFixedOffsetTimeZone() {
+        return fixedOffsetTimeZone;
+    }
+
+    public LocalTime getReferenceTime() {
+        return referenceTime;
     }
 }
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/BeatrixIntegrationModuleNoDB.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/BeatrixIntegrationModuleNoDB.java
index 4c47137..d4e84f4 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/BeatrixIntegrationModuleNoDB.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/BeatrixIntegrationModuleNoDB.java
@@ -21,8 +21,11 @@ import org.killbill.billing.GuicyKillbillTestNoDBModule;
 import org.killbill.billing.mock.glue.MockAccountModule;
 import org.killbill.billing.mock.glue.MockNonEntityDaoModule;
 import org.killbill.billing.platform.api.KillbillConfigSource;
+import org.killbill.billing.util.cache.CacheControllerDispatcher;
 import org.killbill.billing.util.glue.KillBillModule;
 
+import com.google.inject.util.Providers;
+
 public class BeatrixIntegrationModuleNoDB extends KillBillModule {
 
     public BeatrixIntegrationModuleNoDB(final KillbillConfigSource configSource) {
@@ -32,7 +35,9 @@ public class BeatrixIntegrationModuleNoDB extends KillBillModule {
     @Override
     protected void configure() {
         install(new GuicyKillbillTestNoDBModule(configSource));
+
         install(new MockNonEntityDaoModule(configSource));
         install(new MockAccountModule(configSource));
+        bind(CacheControllerDispatcher.class).toProvider(Providers.<CacheControllerDispatcher>of(null));
     }
 }
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestBillingAlignment.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestBillingAlignment.java
index 9ee5303..d3c58a3 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestBillingAlignment.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestBillingAlignment.java
@@ -39,13 +39,13 @@ public class TestBillingAlignment extends TestIntegrationBase {
 
     @Test(groups = "slow")
     public void testTransitionAccountBAToSubscriptionBA() throws Exception {
-        // Set the BCD to the 25th
-        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(25));
-
         // We take april as it has 30 days (easier to play with BCD)
         // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
         clock.setDay(new LocalDate(2012, 4, 1));
 
+        // Set the BCD to the 25th
+        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(25));
+
         //
         // CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
         // (Start with monthly that has an 'Account' billing alignment)
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueBase.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueBase.java
index 5f5b4e2..29a302c 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueBase.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueBase.java
@@ -63,13 +63,16 @@ public abstract class TestOverdueBase extends TestIntegrationBase {
         final DefaultOverdueConfig config = XMLLoader.getObjectFromStreamNoValidation(is, DefaultOverdueConfig.class);
         overdueConfigCache.loadDefaultOverdueConfig(config);
 
+        productName = "Shotgun";
+        term = BillingPeriod.MONTHLY;
+        paymentPlugin.clear();
+    }
+
+    protected void setupAccount() throws Exception {
         account = createAccountWithNonOsgiPaymentMethod(getAccountData(0));
         assertNotNull(account);
 
         paymentApi.addPaymentMethod(account, UUID.randomUUID().toString(), BeatrixIntegrationModule.NON_OSGI_PLUGIN_NAME, true, paymentMethodPlugin, PLUGIN_PROPERTIES, callContext);
-        productName = "Shotgun";
-        term = BillingPeriod.MONTHLY;
-        paymentPlugin.clear();
     }
 
     protected void checkODState(final String expected) {
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueIntegration.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueIntegration.java
index 2fe3884..530d632 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueIntegration.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueIntegration.java
@@ -120,6 +120,8 @@ public class TestOverdueIntegration extends TestOverdueBase {
         // 2012-05-01T00:03:42.000Z
         clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
 
+        setupAccount();
+
         // Set next invoice to fail and create subscription
         paymentPlugin.makeAllInvoicesFailWithError(true);
         final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
@@ -207,6 +209,8 @@ public class TestOverdueIntegration extends TestOverdueBase {
         // 2012-05-01T00:03:42.000Z
         clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
 
+        setupAccount();
+
         // Set next invoice to fail and create subscription
         paymentPlugin.makeAllInvoicesFailWithError(true);
         final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
@@ -301,6 +305,8 @@ public class TestOverdueIntegration extends TestOverdueBase {
         // 2012-05-01T00:03:42.000Z
         clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
 
+        setupAccount();
+
         // Set next invoice to fail and create subscription
         paymentPlugin.makeAllInvoicesFailWithError(true);
         final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
@@ -402,6 +408,8 @@ public class TestOverdueIntegration extends TestOverdueBase {
         // 2012-05-01T00:03:42.000Z
         clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
 
+        setupAccount();
+
         // Set next invoice to fail and create subscription
         paymentPlugin.makeAllInvoicesFailWithError(true);
         final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
@@ -490,6 +498,8 @@ public class TestOverdueIntegration extends TestOverdueBase {
         // 2012-05-01T00:03:42.000Z
         clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
 
+        setupAccount();
+
         // Set next invoice to fail and create subscription
         paymentPlugin.makeAllInvoicesFailWithError(true);
         final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, BillingPeriod.ANNUAL, NextEvent.CREATE, NextEvent.INVOICE);
@@ -568,6 +578,8 @@ public class TestOverdueIntegration extends TestOverdueBase {
         // 2012-05-01T00:03:42.000Z
         clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
 
+        setupAccount();
+
         // Make sure the account doesn't have any payment method
         accountInternalApi.removePaymentMethod(account.getId(), internalCallContext);
 
@@ -663,6 +675,8 @@ public class TestOverdueIntegration extends TestOverdueBase {
         // 2012-05-01T00:03:42.000Z
         clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
 
+        setupAccount();
+
         // Create a subscription without failing payments
         final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
         bundle = subscriptionApi.getSubscriptionBundle(baseEntitlement.getBundleId(), callContext);
@@ -705,6 +719,8 @@ public class TestOverdueIntegration extends TestOverdueBase {
         // 2012-05-01T00:03:42.000Z
         clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
 
+        setupAccount();
+
         // Create subscription and don't fail payments
         final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
         bundle = subscriptionApi.getSubscriptionBundle(baseEntitlement.getBundleId(), callContext);
@@ -749,6 +765,8 @@ public class TestOverdueIntegration extends TestOverdueBase {
         // 2012-05-01T00:03:42.000Z
         clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
 
+        setupAccount();
+
         // Create subscription and don't fail payments
         final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
         bundle = subscriptionApi.getSubscriptionBundle(baseEntitlement.getBundleId(), callContext);
@@ -794,6 +812,8 @@ public class TestOverdueIntegration extends TestOverdueBase {
         // 2012-05-01T00:03:42.000Z
         clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
 
+        setupAccount();
+
         // Set next invoice to fail and create subscription
         paymentPlugin.makeAllInvoicesFailWithError(true);
         final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
@@ -842,6 +862,8 @@ public class TestOverdueIntegration extends TestOverdueBase {
         // 2012-05-01T00:03:42.000Z
         clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
 
+        setupAccount();
+
         // Set next invoice to fail and create subscription
         paymentPlugin.makeAllInvoicesFailWithError(true);
         final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueWithSubscriptionCancellation.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueWithSubscriptionCancellation.java
index 7011c8a..0214473 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueWithSubscriptionCancellation.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueWithSubscriptionCancellation.java
@@ -69,6 +69,8 @@ public class TestOverdueWithSubscriptionCancellation extends TestOverdueBase {
     public void testCheckSubscriptionCancellation() throws Exception {
         clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
 
+        setupAccount();
+
         // Set next invoice to fail and create subscription
         paymentPlugin.makeAllInvoicesFailWithError(true);
         final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
@@ -115,6 +117,8 @@ public class TestOverdueWithSubscriptionCancellation extends TestOverdueBase {
         // 2012-05-01T00:03:53.000Z
         clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
 
+        setupAccount();
+
         // Set next invoice to fail and create subscription
         paymentPlugin.makeAllInvoicesFailWithError(true);
         final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueWithTags.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueWithTags.java
index 3385436..623f791 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueWithTags.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/overdue/TestOverdueWithTags.java
@@ -69,6 +69,8 @@ public class TestOverdueWithTags extends TestOverdueBase {
     public void testOverdueStateWith_WRITTEN_OFF() throws Exception {
         clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
 
+        setupAccount();
+
         // Set next invoice to fail and create subscription
         paymentPlugin.makeAllInvoicesFailWithError(true);
         final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
@@ -106,9 +108,10 @@ public class TestOverdueWithTags extends TestOverdueBase {
 
     @Test(groups = "slow")
     public void testNonOverdueAccountWith_OVERDUE_ENFORCEMENT_OFF() throws Exception {
-
         clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
 
+        setupAccount();
+
         // Set the OVERDUE_ENFORCEMENT_OFF tag (we set the clear state, hence the blocking event)
         busHandler.pushExpectedEvents(NextEvent.TAG, NextEvent.BLOCK);
         tagUserApi.addTag(account.getId(), ObjectType.ACCOUNT, ControlTagType.OVERDUE_ENFORCEMENT_OFF.getId(), callContext);
@@ -143,9 +146,10 @@ public class TestOverdueWithTags extends TestOverdueBase {
 
     @Test(groups = "slow")
     public void testOverdueAccountWithOverdueEnforcementOffTag() throws Exception {
-
         clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
 
+        setupAccount();
+
         // Set next invoice to fail and create subscription
         paymentPlugin.makeAllInvoicesFailWithError(true);
         final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestBundleTransfer.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestBundleTransfer.java
index e32ab28..547c014 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestBundleTransfer.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestBundleTransfer.java
@@ -55,14 +55,12 @@ public class TestBundleTransfer extends TestIntegrationBase {
 
     @Test(groups = "slow")
     public void testBundleTransferWithBPAnnualOnly() throws Exception {
-        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(3));
-
         // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
-
         final DateTime initialDate = new DateTime(2012, 4, 1, 0, 15, 42, 0, testTimeZone);
-
         clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
 
+        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(3));
+
         final String productName = "Shotgun";
         final BillingPeriod term = BillingPeriod.ANNUAL;
         final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -102,14 +100,12 @@ public class TestBundleTransfer extends TestIntegrationBase {
 
     @Test(groups = "slow")
     public void testBundleTransferWithBPMonthlyOnly() throws Exception {
-        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(0));
-
         // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
-
         final DateTime initialDate = new DateTime(2012, 4, 1, 0, 15, 42, 0, testTimeZone);
-
         clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
 
+        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(0));
+
         final String productName = "Shotgun";
         final BillingPeriod term = BillingPeriod.MONTHLY;
         final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -158,14 +154,12 @@ public class TestBundleTransfer extends TestIntegrationBase {
 
     @Test(groups = "slow")
     public void testBundleTransferWithBPMonthlyOnlyWIthCancellationImm() throws Exception {
-
-        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(9));
-
         // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
-
         final DateTime initialDate = new DateTime(2012, 4, 1, 0, 15, 42, 0, testTimeZone);
-
         clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
+
+        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(9));
+
         final String productName = "Shotgun";
         final BillingPeriod term = BillingPeriod.MONTHLY;
         final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegration.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegration.java
index e832853..ab9e470 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegration.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegration.java
@@ -63,14 +63,14 @@ public class TestIntegration extends TestIntegrationBase {
 
     @Test(groups = "slow")
     public void testCancelBPWithAOTheSameDay() throws Exception {
-        final AccountData accountData = getAccountData(1);
-        final Account account = createAccountWithNonOsgiPaymentMethod(accountData);
-        accountChecker.checkAccount(account.getId(), accountData, callContext);
-
         // We take april as it has 30 days (easier to play with BCD)
         // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
         clock.setDay(new LocalDate(2012, 4, 1));
 
+        final AccountData accountData = getAccountData(1);
+        final Account account = createAccountWithNonOsgiPaymentMethod(accountData);
+        accountChecker.checkAccount(account.getId(), accountData, callContext);
+
         final List<ExpectedInvoiceItemCheck> expectedInvoices = new ArrayList<ExpectedInvoiceItemCheck>();
 
         //
@@ -131,11 +131,11 @@ public class TestIntegration extends TestIntegrationBase {
     public void testBasePlanCompleteWithBillingDayInPast() throws Exception {
         final int billingDay = 31;
         final DateTime initialCreationDate = new DateTime(2012, 2, 1, 0, 3, 42, 0, testTimeZone);
+        // set clock to the initial start date
+        clock.setTime(initialCreationDate);
 
         final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(billingDay));
 
-        // set clock to the initial start date
-        clock.setTime(initialCreationDate);
         int invoiceItemCount = 1;
 
         final List<ExpectedInvoiceItemCheck> expectedInvoices = new ArrayList<ExpectedInvoiceItemCheck>();
@@ -243,11 +243,11 @@ public class TestIntegration extends TestIntegrationBase {
     public void testBasePlanCompleteWithBillingDayAlignedWithTrial() throws Exception {
         final int billingDay = 2;
         final DateTime initialCreationDate = new DateTime(2012, 2, 1, 0, 3, 42, 0, testTimeZone);
+        // set clock to the initial start date
+        clock.setTime(initialCreationDate);
 
         final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(billingDay));
 
-        // set clock to the initial start date
-        clock.setTime(initialCreationDate);
         int invoiceItemCount = 1;
 
         //
@@ -334,11 +334,11 @@ public class TestIntegration extends TestIntegrationBase {
     public void testBasePlanCompleteWithBillingDayInFuture() throws Exception {
         final int billingDay = 3;
         final DateTime initialCreationDate = new DateTime(2012, 2, 1, 0, 3, 42, 0, testTimeZone);
+        // set clock to the initial start date
+        clock.setTime(initialCreationDate);
 
         final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(billingDay));
 
-        // set clock to the initial start date
-        clock.setTime(initialCreationDate);
         int invoiceItemCount = 1;
 
         //
@@ -545,14 +545,13 @@ public class TestIntegration extends TestIntegrationBase {
     public void testWithPauseResume() throws Exception {
         final DateTime initialDate = new DateTime(2012, 2, 1, 0, 3, 42, 0, testTimeZone);
         final int billingDay = 2;
+        // set clock to the initial start date
+        clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
 
         final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(billingDay));
         final UUID accountId = account.getId();
         assertNotNull(account);
 
-        // set clock to the initial start date
-        clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
-
         final String productName = "Shotgun";
         final BillingPeriod term = BillingPeriod.MONTHLY;
         final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationBase.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationBase.java
index ef2a9d0..caff3d5 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationBase.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationBase.java
@@ -362,9 +362,7 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
         final Account account = accountUserApi.createAccount(accountData, callContext);
         assertNotNull(account);
 
-        final Long accountRecordId = nonEntityDao.retrieveRecordIdFromObject(account.getId(), ObjectType.ACCOUNT, controlCacheDispatcher.getCacheController(CacheType.RECORD_ID));
-        internalCallContext.setAccountRecordId(accountRecordId);
-        internalCallContext.setReferenceDateTimeZone(account.getTimeZone());
+        refreshCallContext(account.getId());
 
         final PaymentMethodPlugin info = createPaymentMethodPlugin();
 
@@ -586,7 +584,7 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB {
                     assertNotNull(entitlement);
                     return entitlement;
                 } catch (final EntitlementApiException e) {
-                    fail();
+                    fail(e.toString());
                     return null;
                 }
             }
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationInvoice.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationInvoice.java
index f383f99..399d45f 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationInvoice.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationInvoice.java
@@ -38,9 +38,7 @@ import org.killbill.billing.invoice.api.Invoice;
 import org.killbill.billing.invoice.api.InvoiceItemType;
 import org.killbill.billing.payment.api.Payment;
 import org.killbill.billing.payment.api.PluginProperty;
-import org.killbill.billing.payment.dao.PaymentTransactionModelDao;
 import org.killbill.billing.subscription.api.user.DefaultSubscriptionBase;
-import org.testng.Assert;
 import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableList;
@@ -55,15 +53,14 @@ public class TestIntegrationInvoice extends TestIntegrationBase {
     //
     @Test(groups = "slow")
     public void testDryRunWithNoTargetDate() throws Exception {
-
         final int billingDay = 14;
         final DateTime initialCreationDate = new DateTime(2015, 5, 15, 0, 0, 0, 0, testTimeZone);
+        // set clock to the initial start date
+        clock.setTime(initialCreationDate);
 
         log.info("Beginning test with BCD of " + billingDay);
         final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(billingDay));
 
-        // set clock to the initial start date
-        clock.setTime(initialCreationDate);
         int invoiceItemCount = 1;
 
         //
@@ -111,7 +108,6 @@ public class TestIntegrationInvoice extends TestIntegrationBase {
         invoiceChecker.checkInvoiceNoAudits(dryRunInvoice, callContext, expectedInvoices);
     }
 
-
     //
     // More sophisticated test with two non aligned subscriptions that verifies the behavior of using invoice dryRun api with no date
     // - The first subscription is an annual (SUBSCRIPTION aligned) whose billingDate is the first (we start on Jan 2nd to take into account the 30 days trial)
@@ -121,14 +117,13 @@ public class TestIntegrationInvoice extends TestIntegrationBase {
     //
     @Test(groups = "slow")
     public void testDryRunWithNoTargetDateAndMultipleNonAlignedSubscriptions() throws Exception {
-
-        // billing date for the monthly
-        final int billingDay = 14;
-
         // Set in such a way that annual billing date will be the 1st
         final DateTime initialCreationDate = new DateTime(2014, 1, 2, 0, 0, 0, 0, testTimeZone);
         clock.setTime(initialCreationDate);
 
+        // billing date for the monthly
+        final int billingDay = 14;
+
         final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(billingDay));
 
         int invoiceItemCount = 1;
@@ -211,22 +206,19 @@ public class TestIntegrationInvoice extends TestIntegrationBase {
         invoiceChecker.checkInvoiceNoAudits(dryRunInvoice, callContext, expectedInvoices);
     }
 
-
     @Test(groups = "slow")
     public void testApplyCreditOnExistingBalance() throws Exception {
-
+        final DateTime initialCreationDate = new DateTime(2015, 5, 15, 0, 0, 0, 0, testTimeZone);
+        // set clock to the initial start date
+        clock.setTime(initialCreationDate);
 
         final int billingDay = 14;
-        final DateTime initialCreationDate = new DateTime(2015, 5, 15, 0, 0, 0, 0, testTimeZone);
 
         log.info("Beginning test with BCD of " + billingDay);
         final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(billingDay));
 
         add_AUTO_PAY_OFF_Tag(account.getId(), ObjectType.ACCOUNT);
 
-        // set clock to the initial start date
-        clock.setTime(initialCreationDate);
-
         createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
 
         // Move through time and verify we get the same invoice
@@ -271,5 +263,4 @@ public class TestIntegrationInvoice extends TestIntegrationBase {
         final Payment payment = payments.get(0);
         assertTrue(payment.getPurchasedAmount().compareTo(new BigDecimal("199.90")) == 0);
     }
-
 }
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationInvoiceWithRepairLogic.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationInvoiceWithRepairLogic.java
index e6dcd92..4d2c87f 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationInvoiceWithRepairLogic.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestIntegrationInvoiceWithRepairLogic.java
@@ -61,11 +61,11 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
     public void testSimplePartialRepairWithItemAdjustment() throws Exception {
         // We take april as it has 30 days (easier to play with BCD)
         final LocalDate today = new LocalDate(2012, 4, 1);
-        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(1));
-
         // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
         clock.setDay(today);
 
+        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(1));
+
         final String productName = "Shotgun";
         final BillingPeriod term = BillingPeriod.MONTHLY;
         final String pricelistName = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -120,8 +120,7 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
         toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
                 new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
                 new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 2), new LocalDate(2012, 5, 2), InvoiceItemType.ITEM_ADJ, new BigDecimal("-10")),
-                // TODO PIERRE The cba start_date/end_date are created using the callcontext
-                new ExpectedInvoiceItemCheck(callContext.getCreatedDate().toLocalDate(), callContext.getCreatedDate().toLocalDate(), InvoiceItemType.CBA_ADJ, new BigDecimal("10")));
+                new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 2), new LocalDate(2012, 5, 2), InvoiceItemType.CBA_ADJ, new BigDecimal("10")));
         invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
 
         //
@@ -138,8 +137,7 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
         toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
                 new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), new LocalDate(2012, 6, 1), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
                 new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 2), new LocalDate(2012, 5, 2), InvoiceItemType.ITEM_ADJ, new BigDecimal("-10")),
-                // TODO PIERRE The cba start_date/end_date are created using the callcontext
-                new ExpectedInvoiceItemCheck(callContext.getCreatedDate().toLocalDate(), callContext.getCreatedDate().toLocalDate(), InvoiceItemType.CBA_ADJ, new BigDecimal("10")));
+                new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 2), new LocalDate(2012, 5, 2), InvoiceItemType.CBA_ADJ, new BigDecimal("10")));
         invoiceChecker.checkInvoice(invoices.get(1).getId(), callContext, toBeChecked);
 
         toBeChecked = ImmutableList.<ExpectedInvoiceItemCheck>of(
@@ -157,11 +155,11 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
     public void testMultiplePartialRepairs() throws Exception {
         // We take april as it has 30 days (easier to play with BCD)
         final LocalDate today = new LocalDate(2012, 4, 1);
-        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(1));
-
         // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
         clock.setDay(today);
 
+        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(1));
+
         final String productName = "Shotgun";
         final BillingPeriod term = BillingPeriod.MONTHLY;
         final String pricelistName = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -373,14 +371,13 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
 
     @Test(groups = "slow")
     public void testPartialRepairWithCompleteRefund() throws Exception {
-
         // We take april as it has 30 days (easier to play with BCD)
         final LocalDate today = new LocalDate(2012, 4, 1);
-        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(1));
-
         // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
         clock.setDeltaFromReality(today.toDateTimeAtCurrentTime(DateTimeZone.UTC).getMillis() - clock.getUTCNow().getMillis());
 
+        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(1));
+
         final String productName = "Shotgun";
         final BillingPeriod term = BillingPeriod.ANNUAL;
         final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -480,13 +477,12 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
 
     @Test(groups = "slow")
     public void testRepairWithFullItemAdjustment() throws Exception {
-
         final LocalDate today = new LocalDate(2013, 7, 19);
-        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(1));
-
         // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
         clock.setDeltaFromReality(today.toDateTimeAtCurrentTime(DateTimeZone.UTC).getMillis() - clock.getUTCNow().getMillis());
 
+        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(1));
+
         final String productName = "Shotgun";
         final BillingPeriod term = BillingPeriod.ANNUAL;
         final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -551,13 +547,12 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
     //
     @Test(groups = "slow")
     public void testRepairWithPartialItemAdjustment() throws Exception {
-
         final LocalDate today = new LocalDate(2013, 7, 19);
-        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(1));
-
         // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
         clock.setDeltaFromReality(today.toDateTimeAtCurrentTime(DateTimeZone.UTC).getMillis() - clock.getUTCNow().getMillis());
 
+        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(1));
+
         final String productName = "Shotgun";
         final BillingPeriod term = BillingPeriod.ANNUAL;
         final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestInvoiceNotifications.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestInvoiceNotifications.java
index 481952d..b13e7dc 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestInvoiceNotifications.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestInvoiceNotifications.java
@@ -41,15 +41,14 @@ public class TestInvoiceNotifications extends TestIntegrationBase {
 
     @Test(groups = "slow")
     public void testInvoiceNotificationBasic() throws Exception {
+        // We take april as it has 30 days (easier to play with BCD)
+        // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
+        clock.setDay(new LocalDate(2012, 4, 1));
 
         final AccountData accountData = getAccountData(1);
         final Account account = createAccountWithNonOsgiPaymentMethod(accountData);
         accountChecker.checkAccount(account.getId(), accountData, callContext);
 
-        // We take april as it has 30 days (easier to play with BCD)
-        // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
-        clock.setDay(new LocalDate(2012, 4, 1));
-
         final DefaultEntitlement bpSubscription = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
 
         // Move to end of trial =>  2012, 4, 24
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestSubscription.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestSubscription.java
index 3c5e59f..410d5ac 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestSubscription.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestSubscription.java
@@ -64,11 +64,11 @@ public class TestSubscription extends TestIntegrationBase {
     public void testForcePolicy() throws Exception {
         // We take april as it has 30 days (easier to play with BCD)
         final LocalDate today = new LocalDate(2012, 4, 1);
-        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(1));
-
         // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
         clock.setDeltaFromReality(today.toDateTimeAtCurrentTime(DateTimeZone.UTC).getMillis() - clock.getUTCNow().getMillis());
 
+        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(1));
+
         final String productName = "Shotgun";
         final BillingPeriod term = BillingPeriod.ANNUAL;
         final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -142,11 +142,11 @@ public class TestSubscription extends TestIntegrationBase {
     public void testChangeOfPlan() throws Exception {
         // We take april as it has 30 days (easier to play with BCD)
         final LocalDate today = new LocalDate(2012, 4, 1);
-        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(1));
-
         // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
         clock.setDeltaFromReality(today.toDateTimeAtCurrentTime(DateTimeZone.UTC).getMillis() - clock.getUTCNow().getMillis());
 
+        final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(1));
+
         final String productName = "Shotgun";
         final BillingPeriod term = BillingPeriod.ANNUAL;
         final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -245,11 +245,8 @@ public class TestSubscription extends TestIntegrationBase {
                 new ExpectedInvoiceItemCheck(initialDate, null, InvoiceItemType.FIXED, new BigDecimal("0"))); // Shotgun
 
         invoiceChecker.checkInvoice(invoices.get(0).getId(), callContext, toBeChecked);
-
     }
 
-
-
     @Test(groups = "slow")
     public void testCancelFutureSubscriptionWithPolicy() throws Exception {
         final LocalDate initialDate = new LocalDate(2015, 9, 1);
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithCatalogPlugin.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithCatalogPlugin.java
index 7afcb20..cf1209a 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithCatalogPlugin.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithCatalogPlugin.java
@@ -1,6 +1,6 @@
 /*
- * Copyright 2014-2015 Groupon, Inc
- * Copyright 2014-2015 The Billing Project, LLC
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
  *
  * The Billing Project licenses this file to you under the Apache License, version 2.0
  * (the "License"); you may not use this file except in compliance with the
@@ -100,16 +100,14 @@ public class TestWithCatalogPlugin extends TestIntegrationBase {
 
     @Test(groups = "slow")
     public void testCreateSubscriptionWithCatalogPlugin() throws Exception {
+        // We take april as it has 30 days (easier to play with BCD)
+        // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
+        clock.setDay(new LocalDate(2012, 4, 1));
 
         final AccountData accountData = getAccountData(1);
         final Account account = createAccountWithNonOsgiPaymentMethod(accountData);
         accountChecker.checkAccount(account.getId(), accountData, callContext);
 
-        // We take april as it has 30 days (easier to play with BCD)
-        // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
-        clock.setDay(new LocalDate(2012, 4, 1));
-
-        //
         // Create original subscription (Trial PHASE) -> $0 invoice.
         final DefaultEntitlement bpSubscription = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", "Pistol", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
         invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 4, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithEntilementPlugin.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithEntilementPlugin.java
index 698b887..12b75ec 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithEntilementPlugin.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithEntilementPlugin.java
@@ -90,18 +90,16 @@ public class TestWithEntilementPlugin extends TestIntegrationBase {
         testEntitlementPluginApi.setPlanPhasePriceOverride(null);
     }
 
-
-        @Test(groups = "slow")
+    @Test(groups = "slow")
     public void testCreateSubscriptionWithEntitlementPlugin() throws Exception {
+        // We take april as it has 30 days (easier to play with BCD)
+        // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
+        clock.setDay(new LocalDate(2012, 4, 1));
 
         final AccountData accountData = getAccountData(1);
         final Account account = createAccountWithNonOsgiPaymentMethod(accountData);
         accountChecker.checkAccount(account.getId(), accountData, callContext);
 
-        // We take april as it has 30 days (easier to play with BCD)
-        // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
-        clock.setDay(new LocalDate(2012, 4, 1));
-
         final List<PlanPhasePriceOverride> overrides = new ArrayList<PlanPhasePriceOverride>();
         overrides.add(new DefaultPlanPhasePriceOverride("shotgun-monthly-evergreen", account.getCurrency(), null, BigDecimal.TEN));
 
@@ -180,5 +178,4 @@ public class TestWithEntilementPlugin extends TestIntegrationBase {
             this.planPhasePriceOverride = planPhasePriceOverride;
         }
     }
-
 }
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithPriceOverride.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithPriceOverride.java
index e437f17..b593ff0 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithPriceOverride.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithPriceOverride.java
@@ -43,15 +43,14 @@ public class TestWithPriceOverride extends TestIntegrationBase {
 
     @Test(groups = "slow")
     public void testCreatWithFixedPriceOverride() throws Exception {
+        // We take april as it has 30 days (easier to play with BCD)
+        // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
+        clock.setDay(new LocalDate(2012, 4, 1));
 
         final AccountData accountData = getAccountData(1);
         final Account account = createAccountWithNonOsgiPaymentMethod(accountData);
         accountChecker.checkAccount(account.getId(), accountData, callContext);
 
-        // We take april as it has 30 days (easier to play with BCD)
-        // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
-        clock.setDay(new LocalDate(2012, 4, 1));
-
         final List<PlanPhasePriceOverride> overrides = new ArrayList<PlanPhasePriceOverride>();
         overrides.add(new DefaultPlanPhasePriceOverride("shotgun-monthly-trial", account.getCurrency(), BigDecimal.ONE, null));
 
@@ -63,15 +62,14 @@ public class TestWithPriceOverride extends TestIntegrationBase {
 
     @Test(groups = "slow")
     public void testCreateWithRecurringPriceOverride() throws Exception {
+        // We take april as it has 30 days (easier to play with BCD)
+        // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
+        clock.setDay(new LocalDate(2012, 4, 1));
 
         final AccountData accountData = getAccountData(1);
         final Account account = createAccountWithNonOsgiPaymentMethod(accountData);
         accountChecker.checkAccount(account.getId(), accountData, callContext);
 
-        // We take april as it has 30 days (easier to play with BCD)
-        // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
-        clock.setDay(new LocalDate(2012, 4, 1));
-
         final List<PlanPhasePriceOverride> overrides = new ArrayList<PlanPhasePriceOverride>();
         overrides.add(new DefaultPlanPhasePriceOverride("shotgun-monthly-evergreen", account.getCurrency(), null, BigDecimal.TEN));
 
@@ -95,15 +93,14 @@ public class TestWithPriceOverride extends TestIntegrationBase {
 
     @Test(groups = "slow")
     public void testChangePlanWithRecurringPriceOverride() throws Exception {
+        // We take april as it has 30 days (easier to play with BCD)
+        // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
+        clock.setDay(new LocalDate(2012, 4, 1));
 
         final AccountData accountData = getAccountData(1);
         final Account account = createAccountWithNonOsgiPaymentMethod(accountData);
         accountChecker.checkAccount(account.getId(), accountData, callContext);
 
-        // We take april as it has 30 days (easier to play with BCD)
-        // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
-        clock.setDay(new LocalDate(2012, 4, 1));
-
         final DefaultEntitlement bpSubscription = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
         // Check bundle after BP got created otherwise we get an error from auditApi.
         subscriptionChecker.checkSubscriptionCreated(bpSubscription.getId(), internalCallContext);
@@ -132,5 +129,4 @@ public class TestWithPriceOverride extends TestIntegrationBase {
 
         invoiceChecker.checkInvoice(account.getId(), 4, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 1), new LocalDate(2012, 7, 1), InvoiceItemType.RECURRING, new BigDecimal("279.95")));
     }
-
 }
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithTaxItems.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithTaxItems.java
index 07726ee..3d6d407 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithTaxItems.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithTaxItems.java
@@ -106,15 +106,14 @@ public class TestWithTaxItems extends TestIntegrationBase {
 
     @Test(groups = "slow")
     public void testBasicTaxItems() throws Exception {
+        // We take april as it has 30 days (easier to play with BCD)
+        // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
+        clock.setDay(new LocalDate(2012, 4, 1));
 
         final AccountData accountData = getAccountData(1);
         final Account account = createAccountWithNonOsgiPaymentMethod(accountData);
         accountChecker.checkAccount(account.getId(), accountData, callContext);
 
-        // We take april as it has 30 days (easier to play with BCD)
-        // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
-        clock.setDay(new LocalDate(2012, 4, 1));
-
         //
         // Create original subscription (Trial PHASE) -> $0 invoice.
         final DefaultEntitlement bpSubscription = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", "Pistol", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/usage/TestConsumableInArrear.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/usage/TestConsumableInArrear.java
index 80ccbac..8ba5a3f 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/usage/TestConsumableInArrear.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/usage/TestConsumableInArrear.java
@@ -60,14 +60,14 @@ public class TestConsumableInArrear extends TestIntegrationBase {
 
     @Test(groups = "slow")
     public void testWithNoUsageInPeriodAndOldUsage() throws Exception {
-        final AccountData accountData = getAccountData(1);
-        final Account account = createAccountWithNonOsgiPaymentMethod(accountData);
-        accountChecker.checkAccount(account.getId(), accountData, callContext);
-
         // We take april as it has 30 days (easier to play with BCD)
         // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
         clock.setDay(new LocalDate(2012, 4, 1));
 
+        final AccountData accountData = getAccountData(1);
+        final Account account = createAccountWithNonOsgiPaymentMethod(accountData);
+        accountChecker.checkAccount(account.getId(), accountData, callContext);
+
         //
         // CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
         //
@@ -128,14 +128,14 @@ public class TestConsumableInArrear extends TestIntegrationBase {
 
     @Test(groups = "slow")
     public void testWithCancellation() throws Exception {
-        final AccountData accountData = getAccountData(1);
-        final Account account = createAccountWithNonOsgiPaymentMethod(accountData);
-        accountChecker.checkAccount(account.getId(), accountData, callContext);
-
         // We take april as it has 30 days (easier to play with BCD)
         // Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
         clock.setDay(new LocalDate(2012, 4, 1));
 
+        final AccountData accountData = getAccountData(1);
+        final Account account = createAccountWithNonOsgiPaymentMethod(accountData);
+        accountChecker.checkAccount(account.getId(), accountData, callContext);
+
         //
         // CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
         //
diff --git a/entitlement/src/main/java/org/killbill/billing/entitlement/api/EntitlementDateHelper.java b/entitlement/src/main/java/org/killbill/billing/entitlement/api/EntitlementDateHelper.java
index 9ab7b85..bef7478 100644
--- a/entitlement/src/main/java/org/killbill/billing/entitlement/api/EntitlementDateHelper.java
+++ b/entitlement/src/main/java/org/killbill/billing/entitlement/api/EntitlementDateHelper.java
@@ -23,7 +23,6 @@ import javax.annotation.Nullable;
 import org.joda.time.DateTime;
 import org.joda.time.DateTimeZone;
 import org.joda.time.LocalDate;
-import org.killbill.billing.account.api.AccountInternalApi;
 import org.killbill.billing.callcontext.InternalTenantContext;
 import org.killbill.clock.Clock;
 
diff --git a/entitlement/src/test/java/org/killbill/billing/entitlement/api/TestEntitlementDateHelper.java b/entitlement/src/test/java/org/killbill/billing/entitlement/api/TestEntitlementDateHelper.java
index 9a22d1d..c3fb0ed 100644
--- a/entitlement/src/test/java/org/killbill/billing/entitlement/api/TestEntitlementDateHelper.java
+++ b/entitlement/src/test/java/org/killbill/billing/entitlement/api/TestEntitlementDateHelper.java
@@ -18,13 +18,16 @@
 
 package org.killbill.billing.entitlement.api;
 
+import java.util.UUID;
+
 import org.joda.time.DateTime;
 import org.joda.time.DateTimeZone;
 import org.joda.time.LocalDate;
+import org.killbill.billing.GuicyKillbillTestSuiteNoDB;
 import org.killbill.billing.account.api.Account;
-import org.killbill.billing.callcontext.InternalTenantContext;
+import org.killbill.billing.account.api.AccountApiException;
 import org.killbill.billing.entitlement.EntitlementTestSuiteNoDB;
-import org.mockito.Mockito;
+import org.killbill.billing.mock.MockAccountBuilder;
 import org.testng.Assert;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -33,54 +36,48 @@ import static org.testng.Assert.assertTrue;
 
 public class TestEntitlementDateHelper extends EntitlementTestSuiteNoDB {
 
-    private Account account;
     private EntitlementDateHelper dateHelper;
 
     @BeforeClass(groups = "fast")
     public void beforeMethod() throws Exception {
         super.beforeClass();
 
-        account = Mockito.mock(Account.class);
-        Mockito.when(accountInternalApi.getAccountByRecordId(Mockito.anyLong(), Mockito.<InternalTenantContext>any())).thenReturn(account);
-        Mockito.when(accountInternalApi.getImmutableAccountDataByRecordId(Mockito.anyLong(), Mockito.<InternalTenantContext>any())).thenReturn(account);
         dateHelper = new EntitlementDateHelper(clock);
         clock.resetDeltaFromReality();
     }
 
     @Test(groups = "fast")
-    public void testWithAccountInUtc() throws EntitlementApiException {
-
+    public void testWithAccountInUtc() throws AccountApiException, EntitlementApiException {
         final LocalDate initialDate = new LocalDate(2013, 8, 7);
         clock.setDay(initialDate.plusDays(1));
 
-        Mockito.when(account.getTimeZone()).thenReturn(DateTimeZone.UTC);
+        final DateTime referenceDateTime = new DateTime(2013, 1, 1, 15, 43, 25, 0, DateTimeZone.UTC);
+        createAccount(DateTimeZone.UTC, referenceDateTime);
 
-        final DateTime refererenceDateTime = new DateTime(2013, 1, 1, 15, 43, 25, 0, DateTimeZone.UTC);
-        final DateTime targetDate = dateHelper.fromLocalDateAndReferenceTime(initialDate, refererenceDateTime, internalCallContext);
+        final DateTime targetDate = dateHelper.fromLocalDateAndReferenceTime(initialDate, referenceDateTime, internalCallContext);
         final DateTime expectedDate = new DateTime(2013, 8, 7, 15, 43, 25, 0, DateTimeZone.UTC);
         Assert.assertEquals(targetDate, expectedDate);
     }
 
     @Test(groups = "fast")
-    public void testWithAccountInUtcMinus8() throws EntitlementApiException {
-
+    public void testWithAccountInUtcMinus8() throws AccountApiException, EntitlementApiException {
         final LocalDate inputDate = new LocalDate(2013, 8, 7);
         // Current time is in the future so we don't go through logic that will default to a Clock.getUTCNow.
         clock.setDay(inputDate.plusDays(3));
 
         final DateTimeZone timeZoneUtcMinus8 = DateTimeZone.forOffsetHours(-8);
-        Mockito.when(account.getTimeZone()).thenReturn(timeZoneUtcMinus8);
-        internalCallContext.setReferenceDateTimeZone(account.getTimeZone());
-
         // We also use a reference time of 1, 28, 10, 0 -> DateTime in accountTimeZone will be (2013, 8, 7, 1, 28, 10)
-        final DateTime refererenceDateTime = new DateTime(2013, 1, 1, 1, 28, 10, 0, DateTimeZone.UTC);
-        final DateTime targetDate = dateHelper.fromLocalDateAndReferenceTime(inputDate, refererenceDateTime, internalCallContext);
+        final DateTime referenceDateTime = new DateTime(2013, 1, 1, 1, 28, 10, 0, DateTimeZone.UTC);
+
+        createAccount(timeZoneUtcMinus8, referenceDateTime);
+
+        final DateTime targetDate = dateHelper.fromLocalDateAndReferenceTime(inputDate, referenceDateTime, internalCallContext);
 
         // Things to verify:
         // 1. Verify the resulting DateTime brings us back into the correct LocalDate (in the account timezone)
         Assert.assertEquals(new LocalDate(targetDate, timeZoneUtcMinus8), inputDate);
         // 2. Verify the resulting DateTime has the same reference time as we indicated (in UTC)
-        Assert.assertEquals(targetDate.toLocalTime(), refererenceDateTime.toLocalTime());
+        Assert.assertEquals(targetDate.toLocalTime(), referenceDateTime.toLocalTime());
 
         //
         // To be more specific, we should find a UTC Date, with the exact specified reference time, and with a LocalDate one day
@@ -90,24 +87,23 @@ public class TestEntitlementDateHelper extends EntitlementTestSuiteNoDB {
     }
 
     @Test(groups = "fast")
-    public void testWithAccountInUtcPlus5() throws EntitlementApiException {
-
+    public void testWithAccountInUtcPlus5() throws AccountApiException, EntitlementApiException {
         final LocalDate inputDate = new LocalDate(2013, 8, 7);
         clock.setDay(inputDate.plusDays(1));
 
         final DateTimeZone timeZoneUtcPlus5 = DateTimeZone.forOffsetHours(+5);
-        Mockito.when(account.getTimeZone()).thenReturn(timeZoneUtcPlus5);
-        internalCallContext.setReferenceDateTimeZone(account.getTimeZone());
-
         // We also use a reference time of 20, 28, 10, 0 -> DateTime in accountTimeZone will be (2013, 8, 7, 20, 28, 10)
-        final DateTime refererenceDateTime = new DateTime(2013, 1, 1, 20, 28, 10, 0, DateTimeZone.UTC);
-        final DateTime targetDate = dateHelper.fromLocalDateAndReferenceTime(inputDate, refererenceDateTime, internalCallContext);
+        final DateTime referenceDateTime = new DateTime(2013, 1, 1, 20, 28, 10, 0, DateTimeZone.UTC);
+
+        createAccount(timeZoneUtcPlus5, referenceDateTime);
+
+        final DateTime targetDate = dateHelper.fromLocalDateAndReferenceTime(inputDate, referenceDateTime, internalCallContext);
 
         // Things to verify:
         // 1. Verify the resulting DateTime brings us back into the correct LocalDate (in the account timezone)
         Assert.assertEquals(new LocalDate(targetDate, timeZoneUtcPlus5), inputDate);
         // 2. Verify the resulting DateTime has the same reference time as we indicated (in UTC)
-        Assert.assertEquals(targetDate.toLocalTime(), refererenceDateTime.toLocalTime());
+        Assert.assertEquals(targetDate.toLocalTime(), referenceDateTime.toLocalTime());
 
         //
         // To be more specific, we should find a UTC Date, with the exact specified reference time, and with a LocalDate one day
@@ -117,12 +113,12 @@ public class TestEntitlementDateHelper extends EntitlementTestSuiteNoDB {
     }
 
     @Test(groups = "fast")
-    public void testIsBeforeOrEqualsToday() {
-
+    public void testIsBeforeOrEqualsToday() throws AccountApiException {
         clock.setTime(new DateTime(2013, 8, 7, 3, 28, 10, 0, DateTimeZone.UTC));
+
         final DateTimeZone timeZoneUtcMinus8 = DateTimeZone.forOffsetHours(-8);
-        Mockito.when(account.getTimeZone()).thenReturn(timeZoneUtcMinus8);
-        internalCallContext.setReferenceDateTimeZone(account.getTimeZone());
+
+        createAccount(timeZoneUtcMinus8, clock.getUTCNow());
 
         final DateTime inputDateEquals = new DateTime(2013, 8, 6, 23, 28, 10, 0, timeZoneUtcMinus8);
         // Check that our input date is greater than now
@@ -131,4 +127,20 @@ public class TestEntitlementDateHelper extends EntitlementTestSuiteNoDB {
         final DateTime referenceDateTimeThatDoesNotMatter = new DateTime();
         assertTrue(dateHelper.isBeforeOrEqualsToday(inputDateEquals, referenceDateTimeThatDoesNotMatter, timeZoneUtcMinus8, internalCallContext));
     }
+
+    private void createAccount(final DateTimeZone dateTimeZone, final DateTime referenceDateTime) throws AccountApiException {
+        final Account accountData = new MockAccountBuilder().externalKey(UUID.randomUUID().toString())
+                                                            .timeZone(dateTimeZone)
+                                                            .createdDate(referenceDateTime)
+                                                            .build();
+
+        GuicyKillbillTestSuiteNoDB.createMockAccount(accountData,
+                                                     accountUserApi,
+                                                     accountInternalApi,
+                                                     immutableAccountInternalApi,
+                                                     nonEntityDao,
+                                                     internalCallContextFactory,
+                                                     callContext,
+                                                     internalCallContext);
+    }
 }
diff --git a/entitlement/src/test/java/org/killbill/billing/entitlement/EntitlementTestSuiteNoDB.java b/entitlement/src/test/java/org/killbill/billing/entitlement/EntitlementTestSuiteNoDB.java
index b4f0792..df95234 100644
--- a/entitlement/src/test/java/org/killbill/billing/entitlement/EntitlementTestSuiteNoDB.java
+++ b/entitlement/src/test/java/org/killbill/billing/entitlement/EntitlementTestSuiteNoDB.java
@@ -20,6 +20,8 @@ package org.killbill.billing.entitlement;
 
 import org.killbill.billing.GuicyKillbillTestSuiteNoDB;
 import org.killbill.billing.account.api.AccountInternalApi;
+import org.killbill.billing.account.api.AccountUserApi;
+import org.killbill.billing.account.api.ImmutableAccountInternalApi;
 import org.killbill.billing.catalog.api.CatalogService;
 import org.killbill.billing.entitlement.block.BlockingChecker;
 import org.killbill.billing.entitlement.dao.BlockingStateDao;
@@ -27,6 +29,7 @@ import org.killbill.billing.entitlement.glue.TestEntitlementModuleNoDB;
 import org.killbill.billing.junction.BlockingInternalApi;
 import org.killbill.billing.subscription.api.SubscriptionBaseInternalApi;
 import org.killbill.billing.tag.TagInternalApi;
+import org.killbill.billing.util.dao.NonEntityDao;
 import org.killbill.billing.util.tag.dao.TagDao;
 import org.killbill.bus.api.PersistentBus;
 import org.testng.annotations.AfterMethod;
@@ -40,8 +43,12 @@ import com.google.inject.Injector;
 public abstract class EntitlementTestSuiteNoDB extends GuicyKillbillTestSuiteNoDB {
 
     @Inject
+    protected AccountUserApi accountUserApi;
+    @Inject
     protected AccountInternalApi accountInternalApi;
     @Inject
+    protected ImmutableAccountInternalApi immutableAccountInternalApi;
+    @Inject
     protected BlockingInternalApi blockingInternalApi;
     @Inject
     protected BlockingStateDao blockingStateDao;
@@ -57,6 +64,8 @@ public abstract class EntitlementTestSuiteNoDB extends GuicyKillbillTestSuiteNoD
     protected TagInternalApi tagInternalApi;
     @Inject
     protected BlockingChecker blockingChecker;
+    @Inject
+    protected NonEntityDao nonEntityDao;
 
     @BeforeClass(groups = "fast")
     protected void beforeClass() throws Exception {
diff --git a/entitlement/src/test/java/org/killbill/billing/entitlement/EntitlementTestSuiteWithEmbeddedDB.java b/entitlement/src/test/java/org/killbill/billing/entitlement/EntitlementTestSuiteWithEmbeddedDB.java
index 82785c0..3ee58a2 100644
--- a/entitlement/src/test/java/org/killbill/billing/entitlement/EntitlementTestSuiteWithEmbeddedDB.java
+++ b/entitlement/src/test/java/org/killbill/billing/entitlement/EntitlementTestSuiteWithEmbeddedDB.java
@@ -1,7 +1,7 @@
 /*
  * Copyright 2010-2013 Ning, Inc.
- * Copyright 2014 Groupon, Inc
- * Copyright 2014 The Billing Project, LLC
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
  *
  * The Billing Project licenses this file to you under the Apache License, version 2.0
  * (the "License"); you may not use this file except in compliance with the
@@ -21,18 +21,14 @@ package org.killbill.billing.entitlement;
 import java.util.UUID;
 
 import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.authc.AuthenticationToken;
-import org.apache.shiro.authc.UsernamePasswordToken;
 import org.apache.shiro.config.Ini;
 import org.apache.shiro.config.IniSecurityManagerFactory;
 import org.apache.shiro.mgt.SecurityManager;
-import org.apache.shiro.subject.Subject;
 import org.apache.shiro.util.Factory;
 import org.apache.shiro.util.ThreadContext;
 import org.joda.time.DateTime;
 import org.joda.time.DateTimeZone;
 import org.killbill.billing.GuicyKillbillTestSuiteWithEmbeddedDB;
-import org.killbill.billing.ObjectType;
 import org.killbill.billing.account.api.Account;
 import org.killbill.billing.account.api.AccountApiException;
 import org.killbill.billing.account.api.AccountData;
@@ -60,7 +56,6 @@ import org.killbill.billing.subscription.api.SubscriptionBaseService;
 import org.killbill.billing.subscription.engine.core.DefaultSubscriptionBaseService;
 import org.killbill.billing.tag.TagInternalApi;
 import org.killbill.billing.util.api.AuditUserApi;
-import org.killbill.billing.util.cache.Cachable.CacheType;
 import org.killbill.billing.util.callcontext.InternalCallContextFactory;
 import org.killbill.billing.util.dao.NonEntityDao;
 import org.killbill.billing.util.tag.dao.TagDao;
@@ -289,9 +284,7 @@ public class EntitlementTestSuiteWithEmbeddedDB extends GuicyKillbillTestSuiteWi
     protected Account createAccount(final AccountData accountData) throws AccountApiException {
         final Account account = accountApi.createAccount(accountData, callContext);
 
-        final Long accountRecordId = nonEntityDao.retrieveRecordIdFromObject(account.getId(), ObjectType.ACCOUNT, controlCacheDispatcher.getCacheController(CacheType.RECORD_ID));
-        internalCallContext.setAccountRecordId(accountRecordId);
-        internalCallContext.setReferenceDateTimeZone(account.getTimeZone());
+        refreshCallContext(account.getId());
 
         return account;
     }
diff --git a/invoice/src/main/java/org/killbill/billing/invoice/api/user/DefaultInvoiceUserApi.java b/invoice/src/main/java/org/killbill/billing/invoice/api/user/DefaultInvoiceUserApi.java
index 0c54347..0a97b1b 100644
--- a/invoice/src/main/java/org/killbill/billing/invoice/api/user/DefaultInvoiceUserApi.java
+++ b/invoice/src/main/java/org/killbill/billing/invoice/api/user/DefaultInvoiceUserApi.java
@@ -1,7 +1,7 @@
 /*
  * Copyright 2010-2013 Ning, Inc.
- * Copyright 2014-2015 Groupon, Inc
- * Copyright 2014-2015 The Billing Project, LLC
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
  *
  * The Billing Project licenses this file to you under the Apache License, version 2.0
  * (the "License"); you may not use this file except in compliance with the
diff --git a/invoice/src/test/java/org/killbill/billing/invoice/TestInvoiceHelper.java b/invoice/src/test/java/org/killbill/billing/invoice/TestInvoiceHelper.java
index 215d650..7da0621 100644
--- a/invoice/src/test/java/org/killbill/billing/invoice/TestInvoiceHelper.java
+++ b/invoice/src/test/java/org/killbill/billing/invoice/TestInvoiceHelper.java
@@ -29,12 +29,13 @@ import javax.inject.Inject;
 import org.joda.time.DateTime;
 import org.joda.time.DateTimeZone;
 import org.joda.time.LocalDate;
-import org.killbill.billing.ObjectType;
+import org.killbill.billing.GuicyKillbillTestSuite;
+import org.killbill.billing.GuicyKillbillTestSuiteNoDB;
 import org.killbill.billing.account.api.Account;
 import org.killbill.billing.account.api.AccountApiException;
-import org.killbill.billing.account.api.AccountData;
 import org.killbill.billing.account.api.AccountInternalApi;
 import org.killbill.billing.account.api.AccountUserApi;
+import org.killbill.billing.account.api.ImmutableAccountInternalApi;
 import org.killbill.billing.callcontext.InternalCallContext;
 import org.killbill.billing.callcontext.InternalTenantContext;
 import org.killbill.billing.callcontext.MutableInternalCallContext;
@@ -78,7 +79,6 @@ import org.killbill.billing.subscription.api.SubscriptionBase;
 import org.killbill.billing.subscription.api.SubscriptionBaseInternalApi;
 import org.killbill.billing.subscription.api.SubscriptionBaseTransitionType;
 import org.killbill.billing.subscription.api.user.SubscriptionBaseApiException;
-import org.killbill.billing.util.cache.Cachable.CacheType;
 import org.killbill.billing.util.cache.CacheControllerDispatcher;
 import org.killbill.billing.util.callcontext.CallContext;
 import org.killbill.billing.util.callcontext.InternalCallContextFactory;
@@ -153,6 +153,7 @@ public class TestInvoiceHelper {
     private final InvoiceGenerator generator;
     private final BillingInternalApi billingApi;
     private final AccountInternalApi accountApi;
+    private final ImmutableAccountInternalApi immutableAccountApi;
     private final InvoicePluginDispatcher invoicePluginDispatcher;
     private final AccountUserApi accountUserApi;
     private final SubscriptionBaseInternalApi subscriptionApi;
@@ -172,12 +173,13 @@ public class TestInvoiceHelper {
 
     @Inject
     public TestInvoiceHelper(final InvoiceGenerator generator, final IDBI dbi,
-                             final BillingInternalApi billingApi, final AccountInternalApi accountApi, final InvoicePluginDispatcher invoicePluginDispatcher, final AccountUserApi accountUserApi, final SubscriptionBaseInternalApi subscriptionApi, final BusService busService,
+                             final BillingInternalApi billingApi, final AccountInternalApi accountApi, final ImmutableAccountInternalApi immutableAccountApi, final InvoicePluginDispatcher invoicePluginDispatcher, final AccountUserApi accountUserApi, final SubscriptionBaseInternalApi subscriptionApi, final BusService busService,
                              final InvoiceDao invoiceDao, final GlobalLocker locker, final Clock clock, final NonEntityDao nonEntityDao, final CacheControllerDispatcher cacheControllerDispatcher, final MutableInternalCallContext internalCallContext, final InvoiceConfig invoiceConfig,
                              final InternalCallContextFactory internalCallContextFactory) {
         this.generator = generator;
         this.billingApi = billingApi;
         this.accountApi = accountApi;
+        this.immutableAccountApi = immutableAccountApi;
         this.invoicePluginDispatcher = invoicePluginDispatcher;
         this.accountUserApi = accountUserApi;
         this.subscriptionApi = subscriptionApi;
@@ -243,23 +245,28 @@ public class TestInvoiceHelper {
     }
 
     public Account createAccount(final CallContext callContext) throws AccountApiException {
-        final AccountData accountData = new MockAccountBuilder().name(UUID.randomUUID().toString().substring(1, 8))
-                                                                .firstNameLength(6)
-                                                                .email(UUID.randomUUID().toString().substring(1, 8))
-                                                                .phone(UUID.randomUUID().toString().substring(1, 8))
-                                                                .migrated(false)
-                                                                .isNotifiedForInvoices(true)
-                                                                .externalKey(UUID.randomUUID().toString().substring(1, 8))
-                                                                .billingCycleDayLocal(31)
-                                                                .currency(accountCurrency)
-                                                                .paymentMethodId(UUID.randomUUID())
-                                                                .timeZone(DateTimeZone.UTC)
-                                                                .build();
-        final Account account = accountUserApi.createAccount(accountData, callContext);
-
-        final Long accountRecordId = nonEntityDao.retrieveRecordIdFromObject(account.getId(), ObjectType.ACCOUNT, cacheControllerDispatcher.getCacheController(CacheType.RECORD_ID));
-        internalCallContext.setAccountRecordId(accountRecordId);
-        internalCallContext.setReferenceDateTimeZone(account.getTimeZone());
+        final Account accountData = new MockAccountBuilder().name(UUID.randomUUID().toString().substring(1, 8))
+                                                            .firstNameLength(6)
+                                                            .email(UUID.randomUUID().toString().substring(1, 8))
+                                                            .phone(UUID.randomUUID().toString().substring(1, 8))
+                                                            .migrated(false)
+                                                            .isNotifiedForInvoices(true)
+                                                            .externalKey(UUID.randomUUID().toString().substring(1, 8))
+                                                            .billingCycleDayLocal(31)
+                                                            .currency(accountCurrency)
+                                                            .paymentMethodId(UUID.randomUUID())
+                                                            .timeZone(DateTimeZone.UTC)
+                                                            .createdDate(clock.getUTCNow())
+                                                            .build();
+
+        final Account account;
+        if (isFastTest()) {
+            account = GuicyKillbillTestSuiteNoDB.createMockAccount(accountData, accountUserApi, accountApi, immutableAccountApi, nonEntityDao, internalCallContextFactory, callContext, internalCallContext);
+        } else {
+            account = accountUserApi.createAccount(accountData, callContext);
+        }
+
+        GuicyKillbillTestSuite.refreshCallContext(account.getId(), internalCallContextFactory, callContext, internalCallContext);
 
         return account;
     }
@@ -478,4 +485,9 @@ public class TestInvoiceHelper {
             return null;
         }
     }
+
+    // Unfortunately, this helper is shared across fast and slow tests
+    private boolean isFastTest() {
+        return Mockito.mockingDetails(accountApi).isMock();
+    }
 }
diff --git a/jaxrs/src/test/java/org/killbill/billing/jaxrs/glue/TestJaxrsModuleNoDB.java b/jaxrs/src/test/java/org/killbill/billing/jaxrs/glue/TestJaxrsModuleNoDB.java
index fa2dd35..559d3d4 100644
--- a/jaxrs/src/test/java/org/killbill/billing/jaxrs/glue/TestJaxrsModuleNoDB.java
+++ b/jaxrs/src/test/java/org/killbill/billing/jaxrs/glue/TestJaxrsModuleNoDB.java
@@ -1,7 +1,7 @@
 /*
  * Copyright 2010-2013 Ning, Inc.
- * Copyright 2014 Groupon, Inc
- * Copyright 2014 The Billing Project, LLC
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
  *
  * The Billing Project licenses this file to you under the Apache License, version 2.0
  * (the "License"); you may not use this file except in compliance with the
@@ -18,8 +18,14 @@
 
 package org.killbill.billing.jaxrs.glue;
 
+import org.apache.shiro.mgt.SecurityManager;
 import org.killbill.billing.GuicyKillbillTestNoDBModule;
+import org.killbill.billing.mock.glue.MockAccountModule;
+import org.killbill.billing.mock.glue.MockNonEntityDaoModule;
 import org.killbill.billing.platform.api.KillbillConfigSource;
+import org.killbill.billing.tenant.api.TenantInternalApi;
+import org.killbill.billing.util.glue.CacheModule;
+import org.mockito.Mockito;
 
 public class TestJaxrsModuleNoDB extends TestJaxrsModule {
 
@@ -31,5 +37,11 @@ public class TestJaxrsModuleNoDB extends TestJaxrsModule {
     public void configure() {
         super.configure();
         install(new GuicyKillbillTestNoDBModule(configSource));
+
+        install(new MockNonEntityDaoModule(configSource));
+        install(new MockAccountModule(configSource));
+        install(new CacheModule(configSource));
+        bind(TenantInternalApi.class).toInstance(Mockito.mock(TenantInternalApi.class));
+        bind(SecurityManager.class).toInstance(Mockito.mock(SecurityManager.class));
     }
 }
diff --git a/junction/src/test/java/org/killbill/billing/junction/JunctionTestSuiteWithEmbeddedDB.java b/junction/src/test/java/org/killbill/billing/junction/JunctionTestSuiteWithEmbeddedDB.java
index 7c03083..568a786 100644
--- a/junction/src/test/java/org/killbill/billing/junction/JunctionTestSuiteWithEmbeddedDB.java
+++ b/junction/src/test/java/org/killbill/billing/junction/JunctionTestSuiteWithEmbeddedDB.java
@@ -216,9 +216,7 @@ public abstract class JunctionTestSuiteWithEmbeddedDB extends GuicyKillbillTestS
     protected Account createAccount(final AccountData accountData) throws AccountApiException {
         final Account account = accountApi.createAccount(accountData, callContext);
 
-        final Long accountRecordId = nonEntityDao.retrieveRecordIdFromObject(account.getId(), ObjectType.ACCOUNT, controlCacheDispatcher.getCacheController(CacheType.RECORD_ID));
-        internalCallContext.setAccountRecordId(accountRecordId);
-        internalCallContext.setReferenceDateTimeZone(account.getTimeZone());
+        refreshCallContext(account.getId());
 
         return account;
     }
diff --git a/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApiNoDB.java b/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApiNoDB.java
index c19453b..83a2b65 100644
--- a/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApiNoDB.java
+++ b/payment/src/test/java/org/killbill/billing/payment/api/TestPaymentApiNoDB.java
@@ -74,7 +74,7 @@ public class TestPaymentApiNoDB extends PaymentTestSuiteNoDB {
     public void beforeMethod() throws Exception {
         super.beforeMethod();
         final PaymentMethodPlugin paymentMethodInfo = new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), true, null);
-        testHelper.addTestPaymentMethod(account, paymentMethodInfo);
+        account = testHelper.addTestPaymentMethod(account, paymentMethodInfo);
     }
 
     @Test(groups = "fast")
@@ -169,18 +169,15 @@ public class TestPaymentApiNoDB extends PaymentTestSuiteNoDB {
         final PaymentMethod initDefaultMethod = methods.get(0);
         assertEquals(initDefaultMethod.getId(), account.getPaymentMethodId());
 
-        final PaymentMethodPlugin newPaymenrMethod = new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), true, null);
-        final UUID newPaymentMethodId = paymentApi.addPaymentMethod(account, UUID.randomUUID().toString(), MockPaymentProviderPlugin.PLUGIN_NAME, true, newPaymenrMethod, PLUGIN_PROPERTIES, callContext);
-        Mockito.when(account.getPaymentMethodId()).thenReturn(newPaymentMethodId);
+        final PaymentMethodPlugin newPaymentMethod = new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), true, null);
+        account = testHelper.addTestPaymentMethod(account, newPaymentMethod, PLUGIN_PROPERTIES);
 
         methods = paymentApi.getAccountPaymentMethods(account.getId(), false, PLUGIN_PROPERTIES, callContext);
         assertEquals(methods.size(), 2);
 
-        assertEquals(newPaymentMethodId, account.getPaymentMethodId());
-
         boolean failed = false;
         try {
-            paymentApi.deletePaymentMethod(account, newPaymentMethodId, false, PLUGIN_PROPERTIES, callContext);
+            paymentApi.deletePaymentMethod(account, account.getPaymentMethodId(), false, PLUGIN_PROPERTIES, callContext);
         } catch (final PaymentApiException e) {
             failed = true;
         }
@@ -191,7 +188,7 @@ public class TestPaymentApiNoDB extends PaymentTestSuiteNoDB {
         assertEquals(methods.size(), 1);
 
         // NOW retry with default payment method with special flag
-        paymentApi.deletePaymentMethod(account, newPaymentMethodId, true, PLUGIN_PROPERTIES, callContext);
+        paymentApi.deletePaymentMethod(account, account.getPaymentMethodId(), true, PLUGIN_PROPERTIES, callContext);
 
         methods = paymentApi.getAccountPaymentMethods(account.getId(), false, PLUGIN_PROPERTIES, callContext);
         assertEquals(methods.size(), 0);
diff --git a/payment/src/test/java/org/killbill/billing/payment/TestPaymentHelper.java b/payment/src/test/java/org/killbill/billing/payment/TestPaymentHelper.java
index f32c37e..e52d7a3 100644
--- a/payment/src/test/java/org/killbill/billing/payment/TestPaymentHelper.java
+++ b/payment/src/test/java/org/killbill/billing/payment/TestPaymentHelper.java
@@ -1,7 +1,7 @@
 /*
  * Copyright 2010-2013 Ning, Inc.
- * Copyright 2014-2015 Groupon, Inc
- * Copyright 2014-2015 The Billing Project, LLC
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
  *
  * The Billing Project licenses this file to you under the Apache License, version 2.0
  * (the "License"); you may not use this file except in compliance with the
@@ -20,29 +20,31 @@ package org.killbill.billing.payment;
 
 import java.util.UUID;
 
+import org.joda.time.DateTimeZone;
 import org.joda.time.LocalDate;
-import org.killbill.billing.ObjectType;
+import org.killbill.billing.GuicyKillbillTestSuite;
+import org.killbill.billing.GuicyKillbillTestSuiteNoDB;
 import org.killbill.billing.account.api.Account;
 import org.killbill.billing.account.api.AccountInternalApi;
 import org.killbill.billing.account.api.AccountUserApi;
+import org.killbill.billing.account.api.ImmutableAccountInternalApi;
 import org.killbill.billing.callcontext.InternalCallContext;
 import org.killbill.billing.callcontext.InternalTenantContext;
 import org.killbill.billing.callcontext.MutableInternalCallContext;
 import org.killbill.billing.catalog.api.Currency;
-import org.killbill.billing.dao.MockNonEntityDao;
 import org.killbill.billing.events.InvoiceCreationInternalEvent;
 import org.killbill.billing.invoice.api.Invoice;
 import org.killbill.billing.invoice.api.InvoiceApiException;
 import org.killbill.billing.invoice.api.InvoiceInternalApi;
 import org.killbill.billing.invoice.api.InvoiceItem;
+import org.killbill.billing.mock.MockAccountBuilder;
 import org.killbill.billing.payment.api.PaymentApi;
 import org.killbill.billing.payment.api.PaymentMethodPlugin;
 import org.killbill.billing.payment.api.PluginProperty;
 import org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin;
 import org.killbill.billing.payment.provider.MockPaymentProviderPlugin;
-import org.killbill.billing.util.cache.Cachable.CacheType;
-import org.killbill.billing.util.cache.CacheControllerDispatcher;
 import org.killbill.billing.util.callcontext.CallContext;
+import org.killbill.billing.util.callcontext.InternalCallContextFactory;
 import org.killbill.billing.util.dao.NonEntityDao;
 import org.killbill.bus.api.PersistentBus;
 import org.killbill.bus.api.PersistentBus.EventBusException;
@@ -56,38 +58,38 @@ public class TestPaymentHelper {
 
     protected final AccountUserApi accountApi;
     protected final AccountInternalApi accountInternalApi;
+    protected final ImmutableAccountInternalApi immutableAccountInternalApi;
     protected final InvoiceInternalApi invoiceApi;
-    protected PaymentApi paymentApi;
     private final PersistentBus eventBus;
     private final Clock clock;
     private final NonEntityDao nonEntityDao;
-    private final MockNonEntityDao mockNonEntityDao;
-    private final CacheControllerDispatcher cacheControllerDispatcher;
     private final MutableInternalCallContext internalCallContext;
+    private final InternalCallContextFactory internalCallContextFactory;
     private final CallContext context;
+    protected PaymentApi paymentApi;
 
     @Inject
     public TestPaymentHelper(final AccountUserApi accountApi,
                              final AccountInternalApi accountInternalApi,
+                             final ImmutableAccountInternalApi immutableAccountInternalApi,
                              final InvoiceInternalApi invoiceApi,
                              final PaymentApi paymentApi,
                              final PersistentBus eventBus,
                              final Clock clock,
                              final NonEntityDao nonEntityDao,
-                             final MockNonEntityDao mockNonEntityDao,
-                             final CacheControllerDispatcher cacheControllerDispatcher,
                              final MutableInternalCallContext internalCallContext,
+                             final InternalCallContextFactory internalCallContextFactory,
                              final CallContext context) {
         this.accountApi = accountApi;
         this.eventBus = eventBus;
         this.accountInternalApi = accountInternalApi;
+        this.immutableAccountInternalApi = immutableAccountInternalApi;
         this.invoiceApi = invoiceApi;
         this.paymentApi = paymentApi;
         this.clock = clock;
         this.nonEntityDao = nonEntityDao;
-        this.mockNonEntityDao = mockNonEntityDao;
-        this.cacheControllerDispatcher = cacheControllerDispatcher;
         this.internalCallContext = internalCallContext;
+        this.internalCallContextFactory = internalCallContextFactory;
         this.context = context;
     }
 
@@ -141,22 +143,17 @@ public class TestPaymentHelper {
         Mockito.when(accountData.getBillCycleDayLocal()).thenReturn(1);
         Mockito.when(accountData.isMigrated()).thenReturn(false);
         Mockito.when(accountData.isNotifiedForInvoices()).thenReturn(false);
+        Mockito.when(accountData.getTimeZone()).thenReturn(DateTimeZone.UTC);
+        Mockito.when(accountData.getCreatedDate()).thenReturn(clock.getUTCNow());
 
         Account account;
         if (isFastTest()) {
-            account = accountData;
-            Mockito.when(accountInternalApi.getAccountById(Mockito.<UUID>any(), Mockito.<InternalTenantContext>any())).thenReturn(account);
-            Mockito.when(accountInternalApi.getAccountByKey(Mockito.anyString(), Mockito.<InternalTenantContext>any())).thenReturn(account);
-            mockNonEntityDao.addTenantRecordIdMapping(account.getId(), internalCallContext);
-            mockNonEntityDao.addAccountRecordIdMapping(account.getId(), internalCallContext);
+            account = GuicyKillbillTestSuiteNoDB.createMockAccount(accountData, accountApi, accountInternalApi, immutableAccountInternalApi, nonEntityDao, internalCallContextFactory, context, internalCallContext);
         } else {
             account = accountApi.createAccount(accountData, context);
-
-            final Long accountRecordId = nonEntityDao.retrieveRecordIdFromObject(account.getId(), ObjectType.ACCOUNT, cacheControllerDispatcher.getCacheController(CacheType.RECORD_ID));
-            internalCallContext.setAccountRecordId(accountRecordId);
         }
 
-        internalCallContext.setReferenceDateTimeZone(account.getTimeZone());
+        GuicyKillbillTestSuite.refreshCallContext(account.getId(), internalCallContextFactory, context, internalCallContext);
 
         if (addPaymentMethod) {
             final PaymentMethodPlugin pm = new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), true, null);
@@ -167,10 +164,15 @@ public class TestPaymentHelper {
     }
 
     public Account addTestPaymentMethod(final Account account, final PaymentMethodPlugin paymentMethodInfo) throws Exception {
-        final UUID paymentMethodId = paymentApi.addPaymentMethod(account, paymentMethodInfo.getExternalPaymentMethodId(), MockPaymentProviderPlugin.PLUGIN_NAME, true, paymentMethodInfo, ImmutableList.<PluginProperty>of(), context);
+        return addTestPaymentMethod(account, paymentMethodInfo, ImmutableList.<PluginProperty>of());
+    }
+
+    public Account addTestPaymentMethod(final Account account, final PaymentMethodPlugin paymentMethodInfo, final Iterable<PluginProperty> pluginProperties) throws Exception {
+        final UUID paymentMethodId = paymentApi.addPaymentMethod(account, paymentMethodInfo.getExternalPaymentMethodId(), MockPaymentProviderPlugin.PLUGIN_NAME, true, paymentMethodInfo, pluginProperties, context);
         if (isFastTest()) {
-            Mockito.when(account.getPaymentMethodId()).thenReturn(paymentMethodId);
-            return account;
+            final Account account1 = new MockAccountBuilder(account).paymentMethodId(paymentMethodId).build();
+            accountApi.updateAccount(account, context);
+            return account1;
         } else {
             // To reflect the payment method id change
             return accountApi.getAccountById(account.getId(), context);
diff --git a/profiles/killbill/pom.xml b/profiles/killbill/pom.xml
index 81ad8e6..20c2b32 100644
--- a/profiles/killbill/pom.xml
+++ b/profiles/killbill/pom.xml
@@ -308,6 +308,12 @@
         </dependency>
         <dependency>
             <groupId>org.kill-bill.commons</groupId>
+            <artifactId>killbill-queue</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.kill-bill.commons</groupId>
             <artifactId>killbill-skeleton</artifactId>
         </dependency>
         <dependency>
diff --git a/profiles/killbill/src/test/java/org/killbill/billing/server/log/ServerTestSuiteNoDB.java b/profiles/killbill/src/test/java/org/killbill/billing/server/log/ServerTestSuiteNoDB.java
index 7bdf408..f0e5e86 100644
--- a/profiles/killbill/src/test/java/org/killbill/billing/server/log/ServerTestSuiteNoDB.java
+++ b/profiles/killbill/src/test/java/org/killbill/billing/server/log/ServerTestSuiteNoDB.java
@@ -28,7 +28,7 @@ public abstract class ServerTestSuiteNoDB extends GuicyKillbillTestSuiteNoDB {
 
     @BeforeClass(groups = "fast")
     protected void beforeClass() throws Exception {
-        final Injector injector = Guice.createInjector(new GuicyKillbillTestModule(configSource));
+        final Injector injector = Guice.createInjector(new TestServerModuleNoDB(configSource));
         injector.injectMembers(this);
     }
 }
diff --git a/profiles/killbill/src/test/java/org/killbill/billing/server/log/TestServerModuleNoDB.java b/profiles/killbill/src/test/java/org/killbill/billing/server/log/TestServerModuleNoDB.java
new file mode 100644
index 0000000..12744ce
--- /dev/null
+++ b/profiles/killbill/src/test/java/org/killbill/billing/server/log/TestServerModuleNoDB.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
+ *
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at:
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.killbill.billing.server.log;
+
+import org.killbill.billing.GuicyKillbillTestNoDBModule;
+import org.killbill.billing.mock.glue.MockAccountModule;
+import org.killbill.billing.mock.glue.MockNonEntityDaoModule;
+import org.killbill.billing.platform.api.KillbillConfigSource;
+import org.killbill.billing.util.cache.CacheControllerDispatcher;
+import org.killbill.billing.util.glue.KillBillModule;
+
+import com.google.inject.util.Providers;
+
+public class TestServerModuleNoDB extends KillBillModule {
+
+    public TestServerModuleNoDB(final KillbillConfigSource configSource) {
+        super(configSource);
+    }
+
+    @Override
+    public void configure() {
+        install(new GuicyKillbillTestNoDBModule(configSource));
+
+        install(new MockNonEntityDaoModule(configSource));
+        install(new MockAccountModule(configSource));
+        bind(CacheControllerDispatcher.class).toProvider(Providers.<CacheControllerDispatcher>of(null));
+    }
+}
diff --git a/subscription/src/test/java/org/killbill/billing/subscription/SubscriptionTestSuiteWithEmbeddedDB.java b/subscription/src/test/java/org/killbill/billing/subscription/SubscriptionTestSuiteWithEmbeddedDB.java
index 0dc88d7..dd5cb33 100644
--- a/subscription/src/test/java/org/killbill/billing/subscription/SubscriptionTestSuiteWithEmbeddedDB.java
+++ b/subscription/src/test/java/org/killbill/billing/subscription/SubscriptionTestSuiteWithEmbeddedDB.java
@@ -136,9 +136,7 @@ public class SubscriptionTestSuiteWithEmbeddedDB extends GuicyKillbillTestSuiteW
     protected Account createAccount(final AccountData accountData) throws AccountApiException {
         final Account account = accountUserApi.createAccount(accountData, callContext);
 
-        final Long accountRecordId = nonEntityDao.retrieveRecordIdFromObject(account.getId(), ObjectType.ACCOUNT, controlCacheDispatcher.getCacheController(CacheType.RECORD_ID));
-        internalCallContext.setAccountRecordId(accountRecordId);
-        internalCallContext.setReferenceDateTimeZone(account.getTimeZone());
+        refreshCallContext(account.getId());
 
         return account;
     }

usage/pom.xml 5(+5 -0)

diff --git a/usage/pom.xml b/usage/pom.xml
index b3dde9e..4d9a683 100644
--- a/usage/pom.xml
+++ b/usage/pom.xml
@@ -55,6 +55,11 @@
         </dependency>
         <dependency>
             <groupId>org.kill-bill.billing</groupId>
+            <artifactId>killbill-account</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.kill-bill.billing</groupId>
             <artifactId>killbill-api</artifactId>
         </dependency>
         <dependency>
diff --git a/usage/src/test/java/org/killbill/billing/usage/glue/TestUsageModuleWithEmbeddedDB.java b/usage/src/test/java/org/killbill/billing/usage/glue/TestUsageModuleWithEmbeddedDB.java
index 1e71a18..15078d8 100644
--- a/usage/src/test/java/org/killbill/billing/usage/glue/TestUsageModuleWithEmbeddedDB.java
+++ b/usage/src/test/java/org/killbill/billing/usage/glue/TestUsageModuleWithEmbeddedDB.java
@@ -1,7 +1,7 @@
 /*
  * Copyright 2010-2013 Ning, Inc.
- * Copyright 2014 Groupon, Inc
- * Copyright 2014 The Billing Project, LLC
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
  *
  * The Billing Project licenses this file to you under the Apache License, version 2.0
  * (the "License"); you may not use this file except in compliance with the
@@ -19,6 +19,7 @@
 package org.killbill.billing.usage.glue;
 
 import org.killbill.billing.GuicyKillbillTestWithEmbeddedDBModule;
+import org.killbill.billing.account.glue.DefaultAccountModule;
 import org.killbill.billing.platform.api.KillbillConfigSource;
 import org.killbill.billing.util.glue.CacheModule;
 import org.killbill.billing.util.glue.NonEntityDaoModule;
@@ -36,5 +37,6 @@ public class TestUsageModuleWithEmbeddedDB extends TestUsageModule {
         install(new GuicyKillbillTestWithEmbeddedDBModule(configSource));
         install(new CacheModule(configSource));
         install(new NonEntityDaoModule(configSource));
+        install(new DefaultAccountModule(configSource));
     }
 }
diff --git a/util/src/main/java/org/killbill/billing/util/account/AccountDateTimeUtils.java b/util/src/main/java/org/killbill/billing/util/account/AccountDateTimeUtils.java
new file mode 100644
index 0000000..6ab4322
--- /dev/null
+++ b/util/src/main/java/org/killbill/billing/util/account/AccountDateTimeUtils.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2016 Groupon, Inc
+ * Copyright 2016 The Billing Project, LLC
+ *
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
+ * (the "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at:
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.killbill.billing.util.account;
+
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.killbill.billing.account.api.Account;
+
+public abstract class AccountDateTimeUtils {
+
+    public static DateTimeZone getFixedOffsetTimeZone(final Account account) {
+        final DateTimeZone referenceDateTimeZone = account.getTimeZone();
+        final DateTime referenceDateTime = getReferenceDateTime(account);
+
+        // Check if DST was in effect at the reference date time
+        final boolean shouldUseDST = !referenceDateTimeZone.isStandardOffset(referenceDateTime.getMillis());
+        if (shouldUseDST) {
+            return DateTimeZone.forOffsetMillis(referenceDateTimeZone.getOffset(referenceDateTime.getMillis()));
+        } else {
+            return DateTimeZone.forOffsetMillis(referenceDateTimeZone.getStandardOffset(referenceDateTime.getMillis()));
+        }
+    }
+
+    public static DateTime getReferenceDateTime(final Account account) {
+        return account.getCreatedDate();
+    }
+}
diff --git a/util/src/main/java/org/killbill/billing/util/callcontext/InternalCallContextFactory.java b/util/src/main/java/org/killbill/billing/util/callcontext/InternalCallContextFactory.java
index 0460fd4..348dd21 100644
--- a/util/src/main/java/org/killbill/billing/util/callcontext/InternalCallContextFactory.java
+++ b/util/src/main/java/org/killbill/billing/util/callcontext/InternalCallContextFactory.java
@@ -1,7 +1,7 @@
 /*
  * Copyright 2010-2012 Ning, Inc.
- * Copyright 2014-2015 Groupon, Inc
- * Copyright 2014-2015 The Billing Project, LLC
+ * Copyright 2014-2016 Groupon, Inc
+ * Copyright 2014-2016 The Billing Project, LLC
  *
  * The Billing Project licenses this file to you under the Apache License, version 2.0
  * (the "License"); you may not use this file except in compliance with the
@@ -27,7 +27,6 @@ import org.joda.time.DateTime;
 import org.joda.time.DateTimeZone;
 import org.killbill.billing.ObjectType;
 import org.killbill.billing.account.api.AccountApiException;
-import org.killbill.billing.account.api.AccountInternalApi;
 import org.killbill.billing.account.api.ImmutableAccountData;
 import org.killbill.billing.account.api.ImmutableAccountInternalApi;
 import org.killbill.billing.callcontext.InternalCallContext;
@@ -133,7 +132,7 @@ public class InternalCallContextFactory {
         if (accountRecordId == null) {
             return new InternalTenantContext(tenantRecordId);
         } else {
-            return new InternalTenantContext(tenantRecordId, accountRecordId, getAccountTimeZone(tenantRecordId, accountRecordId));
+            return new InternalTenantContext(tenantRecordId, accountRecordId, getFixedOffsetTimeZone(accountRecordId, tenantRecordId), getReferenceTime(accountRecordId, tenantRecordId));
         }
     }
 
@@ -171,15 +170,14 @@ public class InternalCallContextFactory {
 
         return createInternalCallContext(objectId, objectType, context.getUserName(), context.getCallOrigin(),
                                          context.getUserType(), context.getUserToken(), context.getReasonCode(), context.getComments(),
-                                         context.getCreatedDate(), context.getUpdatedDate(), context);
+                                         context);
     }
 
     // Used by the payment retry service
     public InternalCallContext createInternalCallContext(final UUID objectId, final ObjectType objectType, final String userName,
                                                          final CallOrigin callOrigin, final UserType userType, @Nullable final UUID userToken, final Long tenantRecordId) {
         final Long accountRecordId = getAccountRecordIdSafe(objectId, objectType, tenantRecordId);
-        return createInternalCallContext(tenantRecordId, accountRecordId, userName, callOrigin, userType, userToken,
-                                         null, null, clock.getUTCNow(), clock.getUTCNow());
+        return createInternalCallContext(tenantRecordId, accountRecordId, userName, callOrigin, userType, userToken, null, null);
     }
 
     /**
@@ -197,7 +195,7 @@ public class InternalCallContextFactory {
      */
     public InternalCallContext createInternalCallContext(@Nullable final Long tenantRecordId, @Nullable final Long accountRecordId, final String userName,
                                                          final CallOrigin callOrigin, final UserType userType, @Nullable final UUID userToken) {
-        return createInternalCallContext(tenantRecordId, accountRecordId, userName, callOrigin, userType, userToken, null, null, clock.getUTCNow(), clock.getUTCNow());
+        return createInternalCallContext(tenantRecordId, accountRecordId, userName, callOrigin, userType, userToken, null, null);
     }
 
     /**
@@ -212,47 +210,72 @@ public class InternalCallContextFactory {
     public InternalCallContext createInternalCallContext(final CallContext context) {
         // If tenant id is null, this will default to the default tenant record id (multi-tenancy disabled)
         final Long tenantRecordId = getTenantRecordIdSafe(context);
-        return new InternalCallContext(tenantRecordId, context);
+        return new InternalCallContext(tenantRecordId, context, clock.getUTCNow());
     }
 
     // Used when we need to re-hydrate the callcontext with the account_record_id (when creating the account)
     public InternalCallContext createInternalCallContext(final Long accountRecordId, final InternalCallContext context) {
-        final DateTimeZone accountTimeZone = getAccountTimeZone(context.getTenantRecordId(), accountRecordId);
-        return new InternalCallContext(context, accountRecordId, accountTimeZone);
+        final DateTimeZone fixedOffsetTimeZone = getFixedOffsetTimeZone(accountRecordId, context.getTenantRecordId());
+        final DateTime referenceTime = getReferenceTime(accountRecordId, context.getTenantRecordId());
+        return new InternalCallContext(context, accountRecordId, fixedOffsetTimeZone, referenceTime, clock.getUTCNow());
     }
 
     private InternalCallContext createInternalCallContext(final UUID objectId, final ObjectType objectType, final String userName,
                                                           final CallOrigin callOrigin, final UserType userType, @Nullable final UUID userToken,
-                                                          @Nullable final String reasonCode, @Nullable final String comment, final DateTime createdDate,
-                                                          final DateTime updatedDate, final TenantContext tenantContext) {
+                                                          @Nullable final String reasonCode, @Nullable final String comment,
+                                                          final TenantContext tenantContext) {
         final Long tenantRecordId = getTenantRecordIdSafe(tenantContext);
         final Long accountRecordId = getAccountRecordIdSafe(objectId, objectType, tenantContext);
         return createInternalCallContext(tenantRecordId, accountRecordId, userName, callOrigin, userType, userToken,
-                                         reasonCode, comment, createdDate, updatedDate);
+                                         reasonCode, comment);
     }
 
-    private InternalCallContext createInternalCallContext(@Nullable final Long tenantRecordId, @Nullable  final Long accountRecordId, final String userName,
+    private InternalCallContext createInternalCallContext(@Nullable final Long tenantRecordId, @Nullable final Long accountRecordId, final String userName,
                                                           final CallOrigin callOrigin, final UserType userType, @Nullable final UUID userToken,
-                                                          @Nullable final String reasonCode, @Nullable final String comment, final DateTime createdDate,
-                                                          final DateTime updatedDate) {
+                                                          @Nullable final String reasonCode, @Nullable final String comment) {
         final Long nonNulTenantRecordId = MoreObjects.firstNonNull(tenantRecordId, INTERNAL_TENANT_RECORD_ID);
-        final DateTimeZone accountTimeZone = getAccountTimeZone(tenantRecordId, accountRecordId);
+        final DateTimeZone fixedOffsetTimeZone = getFixedOffsetTimeZone(accountRecordId, tenantRecordId);
+        final DateTime referenceTime = getReferenceTime(accountRecordId, tenantRecordId);
+
+        return new InternalCallContext(nonNulTenantRecordId,
+                                       accountRecordId,
+                                       fixedOffsetTimeZone,
+                                       referenceTime,
+                                       userToken,
+                                       userName,
+                                       callOrigin,
+                                       userType,
+                                       reasonCode,
+                                       comment,
+                                       clock.getUTCNow(),
+                                       clock.getUTCNow());
+    }
+
+    private DateTimeZone getFixedOffsetTimeZone(@Nullable final Long accountRecordId, final Long tenantRecordId) {
+        if (accountRecordId == null || accountInternalApi == null) {
+            return null;
+        }
 
-        return new InternalCallContext(nonNulTenantRecordId, accountRecordId, accountTimeZone, userToken, userName, callOrigin, userType, reasonCode, comment,
-                                       createdDate, updatedDate);
+        final ImmutableAccountData immutableAccountData = getImmutableAccountData(accountRecordId, tenantRecordId);
+        // Will be null while creating the account
+        return immutableAccountData == null ? null : immutableAccountData.getFixedOffsetTimeZone();
     }
 
-    private DateTimeZone getAccountTimeZone(final Long tenantRecordId, @Nullable final Long accountRecordId) {
+    private DateTime getReferenceTime(@Nullable final Long accountRecordId, final Long tenantRecordId) {
         if (accountRecordId == null || accountInternalApi == null) {
             return null;
         }
 
-        final InternalTenantContext tmp = new InternalTenantContext(tenantRecordId, accountRecordId, null);
+        final ImmutableAccountData immutableAccountData = getImmutableAccountData(accountRecordId, tenantRecordId);
+        // Will be null while creating the account
+        return immutableAccountData == null ? null : immutableAccountData.getReferenceTime();
+    }
+
+    private ImmutableAccountData getImmutableAccountData(@Nullable final Long accountRecordId, final Long tenantRecordId) {
+        final InternalTenantContext tmp = new InternalTenantContext(tenantRecordId, accountRecordId, null, null);
 
         try {
-            final ImmutableAccountData immutableAccountData = accountInternalApi.getImmutableAccountDataByRecordId(accountRecordId, tmp);
-            // Will be null while creating the account
-            return immutableAccountData == null ? null : immutableAccountData.getTimeZone();
+            return accountInternalApi.getImmutableAccountDataByRecordId(accountRecordId, tmp);
         } catch (final AccountApiException e) {
             return null;
         }
diff --git a/util/src/test/java/org/killbill/billing/callcontext/MutableInternalCallContext.java b/util/src/test/java/org/killbill/billing/callcontext/MutableInternalCallContext.java
index 6882a8b..2066bcf 100644
--- a/util/src/test/java/org/killbill/billing/callcontext/MutableInternalCallContext.java
+++ b/util/src/test/java/org/killbill/billing/callcontext/MutableInternalCallContext.java
@@ -23,6 +23,7 @@ import javax.annotation.Nullable;
 
 import org.joda.time.DateTime;
 import org.joda.time.DateTimeZone;
+import org.joda.time.LocalTime;
 import org.killbill.billing.util.callcontext.CallOrigin;
 import org.killbill.billing.util.callcontext.UserType;
 
@@ -31,18 +32,21 @@ public class MutableInternalCallContext extends InternalCallContext {
     private final Long initialAccountRecordId;
     private final Long initialTenantRecordId;
     private final DateTimeZone initialReferenceDateTimeZone;
+    private final LocalTime initialReferenceTime;
     private final DateTime initialCreatedDate;
     private final DateTime initialUpdatedDate;
 
     private Long accountRecordId;
     private Long tenantRecordId;
-    private DateTimeZone referenceDateTimeZone;
+    private DateTimeZone fixedOffsetTimeZone;
+    private LocalTime referenceTime;
     private DateTime createdDate;
     private DateTime updatedDate;
 
     public MutableInternalCallContext(final Long tenantRecordId,
                                       @Nullable final Long accountRecordId,
-                                      @Nullable final DateTimeZone referenceDateTimeZone,
+                                      @Nullable final DateTimeZone fixedOffsetTimeZone,
+                                      @Nullable final DateTime referenceTime,
                                       final UUID userToken,
                                       final String userName,
                                       final CallOrigin callOrigin,
@@ -51,10 +55,11 @@ public class MutableInternalCallContext extends InternalCallContext {
                                       final String comment,
                                       final DateTime createdDate,
                                       final DateTime updatedDate) {
-        super(tenantRecordId, accountRecordId, referenceDateTimeZone, userToken, userName, callOrigin, userType, reasonCode, comment, createdDate, updatedDate);
+        super(tenantRecordId, accountRecordId, fixedOffsetTimeZone, referenceTime, userToken, userName, callOrigin, userType, reasonCode, comment, createdDate, updatedDate);
         this.initialAccountRecordId = accountRecordId;
         this.initialTenantRecordId = tenantRecordId;
-        this.initialReferenceDateTimeZone = referenceDateTimeZone;
+        this.initialReferenceDateTimeZone = fixedOffsetTimeZone;
+        this.initialReferenceTime = super.getReferenceTime();
         this.initialCreatedDate = createdDate;
         this.initialUpdatedDate = updatedDate;
 
@@ -80,12 +85,25 @@ public class MutableInternalCallContext extends InternalCallContext {
     }
 
     @Override
-    public DateTimeZone getReferenceDateTimeZone() {
-        return referenceDateTimeZone;
+    public DateTimeZone getFixedOffsetTimeZone() {
+        return fixedOffsetTimeZone;
     }
 
-    public void setReferenceDateTimeZone(final DateTimeZone referenceDateTimeZone) {
-        this.referenceDateTimeZone = referenceDateTimeZone;
+    public void setFixedOffsetTimeZone(final DateTimeZone fixedOffsetTimeZone) {
+        this.fixedOffsetTimeZone = fixedOffsetTimeZone;
+    }
+
+    @Override
+    public LocalTime getReferenceTime() {
+        return referenceTime;
+    }
+
+    public void setReferenceTime(final LocalTime referenceTime) {
+        this.referenceTime = referenceTime;
+    }
+
+    public void setReferenceTime(final DateTime referenceDateTime) {
+        this.referenceTime = computeReferenceTime(referenceDateTime);
     }
 
     @Override
@@ -109,7 +127,8 @@ public class MutableInternalCallContext extends InternalCallContext {
     public void reset() {
         setAccountRecordId(initialAccountRecordId);
         setTenantRecordId(initialTenantRecordId);
-        setReferenceDateTimeZone(initialReferenceDateTimeZone);
+        setFixedOffsetTimeZone(initialReferenceDateTimeZone);
+        setReferenceTime(initialReferenceTime);
         setCreatedDate(initialCreatedDate);
         setUpdatedDate(initialUpdatedDate);
     }
diff --git a/util/src/test/java/org/killbill/billing/GuicyKillbillTestModule.java b/util/src/test/java/org/killbill/billing/GuicyKillbillTestModule.java
index 65f7fa7..3aea65b 100644
--- a/util/src/test/java/org/killbill/billing/GuicyKillbillTestModule.java
+++ b/util/src/test/java/org/killbill/billing/GuicyKillbillTestModule.java
@@ -42,6 +42,7 @@ public class GuicyKillbillTestModule extends KillBillModule {
     private final MutableInternalCallContext internalCallContext = new MutableInternalCallContext(InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID,
                                                                                                   1687L,
                                                                                                   DateTimeZone.UTC,
+                                                                                                  GuicyKillbillTestSuite.getClock().getUTCNow(),
                                                                                                   UUID.randomUUID(),
                                                                                                   UUID.randomUUID().toString(),
                                                                                                   CallOrigin.TEST,
diff --git a/util/src/test/java/org/killbill/billing/GuicyKillbillTestSuite.java b/util/src/test/java/org/killbill/billing/GuicyKillbillTestSuite.java
index b4c5538..2e9b743 100644
--- a/util/src/test/java/org/killbill/billing/GuicyKillbillTestSuite.java
+++ b/util/src/test/java/org/killbill/billing/GuicyKillbillTestSuite.java
@@ -19,13 +19,17 @@
 package org.killbill.billing;
 
 import java.lang.reflect.Method;
+import java.util.UUID;
 
 import javax.inject.Inject;
 
+import org.killbill.billing.callcontext.InternalTenantContext;
 import org.killbill.billing.callcontext.MutableInternalCallContext;
 import org.killbill.billing.platform.api.KillbillConfigSource;
 import org.killbill.billing.platform.test.config.TestKillbillConfigSource;
 import org.killbill.billing.util.callcontext.CallContext;
+import org.killbill.billing.util.callcontext.InternalCallContextFactory;
+import org.killbill.billing.util.callcontext.TenantContext;
 import org.killbill.clock.ClockMock;
 import org.skife.config.ConfigSource;
 import org.slf4j.Logger;
@@ -44,6 +48,9 @@ public class GuicyKillbillTestSuite {
     private boolean hasFailed = false;
 
     @Inject
+    protected InternalCallContextFactory internalCallContextFactory;
+
+    @Inject
     protected MutableInternalCallContext internalCallContext;
 
     @Inject
@@ -95,6 +102,20 @@ public class GuicyKillbillTestSuite {
         return theStaticClock;
     }
 
+    public static void refreshCallContext(final UUID accountId,
+                                          final InternalCallContextFactory internalCallContextFactory,
+                                          final TenantContext callContext,
+                                          final MutableInternalCallContext internalCallContext) {
+        final InternalTenantContext tmp = internalCallContextFactory.createInternalTenantContext(accountId, callContext);
+        internalCallContext.setAccountRecordId(tmp.getAccountRecordId());
+        internalCallContext.setFixedOffsetTimeZone(tmp.getFixedOffsetTimeZone());
+        internalCallContext.setReferenceTime(tmp.getReferenceTime());
+    }
+
+    protected void refreshCallContext(final UUID accountId) {
+        refreshCallContext(accountId, internalCallContextFactory, callContext, internalCallContext);
+    }
+
     @BeforeMethod(alwaysRun = true)
     public void beforeMethodAlwaysRun(final Method method) throws Exception {
         log.info("***************************************************************************************************");
diff --git a/util/src/test/java/org/killbill/billing/GuicyKillbillTestSuiteNoDB.java b/util/src/test/java/org/killbill/billing/GuicyKillbillTestSuiteNoDB.java
index 734aaef..0abf3c0 100644
--- a/util/src/test/java/org/killbill/billing/GuicyKillbillTestSuiteNoDB.java
+++ b/util/src/test/java/org/killbill/billing/GuicyKillbillTestSuiteNoDB.java
@@ -16,7 +16,43 @@
 
 package org.killbill.billing;
 
-public class GuicyKillbillTestSuiteNoDB extends GuicyKillbillTestSuite  {
+import java.util.UUID;
 
+import org.killbill.billing.account.api.Account;
+import org.killbill.billing.account.api.AccountApiException;
+import org.killbill.billing.account.api.AccountInternalApi;
+import org.killbill.billing.account.api.AccountUserApi;
+import org.killbill.billing.account.api.ImmutableAccountInternalApi;
+import org.killbill.billing.callcontext.InternalTenantContext;
+import org.killbill.billing.callcontext.MutableInternalCallContext;
+import org.killbill.billing.dao.MockNonEntityDao;
+import org.killbill.billing.util.callcontext.CallContext;
+import org.killbill.billing.util.callcontext.InternalCallContextFactory;
+import org.killbill.billing.util.dao.NonEntityDao;
+import org.mockito.Mockito;
 
+public class GuicyKillbillTestSuiteNoDB extends GuicyKillbillTestSuite {
+
+    public static Account createMockAccount(final Account accountData,
+                                            final AccountUserApi accountUserApi,
+                                            final AccountInternalApi accountInternalApi,
+                                            final ImmutableAccountInternalApi immutableAccountInternalApi,
+                                            final NonEntityDao nonEntityDao,
+                                            final InternalCallContextFactory internalCallContextFactory,
+                                            final CallContext callContext,
+                                            final MutableInternalCallContext internalCallContext) throws AccountApiException {
+        final Account account = accountUserApi.createAccount(accountData, callContext);
+
+        Mockito.when(accountInternalApi.getAccountById(Mockito.<UUID>eq(account.getId()), Mockito.<InternalTenantContext>any())).thenReturn(account);
+        Mockito.when(accountInternalApi.getAccountByRecordId(Mockito.<Long>eq(internalCallContext.getAccountRecordId()), Mockito.<InternalTenantContext>any())).thenReturn(account);
+        Mockito.when(accountInternalApi.getAccountByKey(Mockito.<String>eq(account.getExternalKey()), Mockito.<InternalTenantContext>any())).thenReturn(account);
+        Mockito.when(immutableAccountInternalApi.getImmutableAccountDataByRecordId(Mockito.<Long>eq(internalCallContext.getAccountRecordId()), Mockito.<InternalTenantContext>any())).thenReturn(account);
+
+        ((MockNonEntityDao) nonEntityDao).addTenantRecordIdMapping(account.getId(), internalCallContext);
+        ((MockNonEntityDao) nonEntityDao).addAccountRecordIdMapping(account.getId(), internalCallContext);
+
+        refreshCallContext(account.getId(), internalCallContextFactory, callContext, internalCallContext);
+
+        return account;
+    }
 }
diff --git a/util/src/test/java/org/killbill/billing/mock/api/MockAccountUserApi.java b/util/src/test/java/org/killbill/billing/mock/api/MockAccountUserApi.java
index 18e47eb..ad55e49 100644
--- a/util/src/test/java/org/killbill/billing/mock/api/MockAccountUserApi.java
+++ b/util/src/test/java/org/killbill/billing/mock/api/MockAccountUserApi.java
@@ -16,13 +16,13 @@
 
 package org.killbill.billing.mock.api;
 
+import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.UUID;
-import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ConcurrentLinkedQueue;
 
 import org.joda.time.DateTimeZone;
-
 import org.killbill.billing.account.api.Account;
 import org.killbill.billing.account.api.AccountApiException;
 import org.killbill.billing.account.api.AccountData;
@@ -34,10 +34,11 @@ import org.killbill.billing.util.callcontext.CallContext;
 import org.killbill.billing.util.callcontext.TenantContext;
 import org.killbill.billing.util.entity.DefaultPagination;
 import org.killbill.billing.util.entity.Pagination;
+import org.testng.Assert;
 
 public class MockAccountUserApi implements AccountUserApi {
 
-    private final CopyOnWriteArrayList<Account> accounts = new CopyOnWriteArrayList<Account>();
+    private final ConcurrentLinkedQueue<Account> accounts = new ConcurrentLinkedQueue<Account>();
 
     public Account createAccountFromParams(final UUID id,
                                            final String externalKey,
@@ -153,7 +154,19 @@ public class MockAccountUserApi implements AccountUserApi {
 
     @Override
     public void updateAccount(final Account account, final CallContext context) {
-        throw new UnsupportedOperationException();
+        final Iterator<Account> iterator = accounts.iterator();
+        while (iterator.hasNext()) {
+            final Account account1 = iterator.next();
+            if (account.getId().equals(account1.getId())) {
+                iterator.remove();
+                break;
+            }
+        }
+        try {
+            createAccount(account, context);
+        } catch (final AccountApiException e) {
+            Assert.fail(e.toString());
+        }
     }
 
     @Override
diff --git a/util/src/test/java/org/killbill/billing/mock/glue/MockAccountModule.java b/util/src/test/java/org/killbill/billing/mock/glue/MockAccountModule.java
index 3fc2521..a96e1b0 100644
--- a/util/src/test/java/org/killbill/billing/mock/glue/MockAccountModule.java
+++ b/util/src/test/java/org/killbill/billing/mock/glue/MockAccountModule.java
@@ -19,18 +19,15 @@
 package org.killbill.billing.mock.glue;
 
 import org.joda.time.DateTimeZone;
-import org.killbill.billing.account.api.AccountApiException;
 import org.killbill.billing.account.api.AccountInternalApi;
 import org.killbill.billing.account.api.AccountUserApi;
 import org.killbill.billing.account.api.ImmutableAccountData;
 import org.killbill.billing.account.api.ImmutableAccountInternalApi;
-import org.killbill.billing.callcontext.InternalTenantContext;
 import org.killbill.billing.glue.AccountModule;
 import org.killbill.billing.mock.api.MockAccountUserApi;
 import org.killbill.billing.platform.api.KillbillConfigSource;
 import org.killbill.billing.util.glue.KillBillModule;
 import org.mockito.Mockito;
-import org.testng.Assert;
 
 public class MockAccountModule extends KillBillModule implements AccountModule {
 
@@ -53,15 +50,10 @@ public class MockAccountModule extends KillBillModule implements AccountModule {
     public void installInternalApi() {
         final ImmutableAccountData immutableAccountData = Mockito.mock(ImmutableAccountData.class);
         Mockito.when(immutableAccountData.getTimeZone()).thenReturn(DateTimeZone.UTC);
+        Mockito.when(immutableAccountData.getFixedOffsetTimeZone()).thenReturn(DateTimeZone.UTC);
 
         final AccountInternalApi accountInternalApi = Mockito.mock(AccountInternalApi.class);
         final ImmutableAccountInternalApi immutableAccountInternalApi = Mockito.mock(ImmutableAccountInternalApi.class);
-        try {
-            Mockito.when(accountInternalApi.getImmutableAccountDataByRecordId(Mockito.anyLong(), Mockito.<InternalTenantContext>any())).thenReturn(immutableAccountData);
-            Mockito.when(immutableAccountInternalApi.getImmutableAccountDataByRecordId(Mockito.anyLong(), Mockito.<InternalTenantContext>any())).thenReturn(immutableAccountData);
-        } catch (final AccountApiException e) {
-            Assert.fail(e.getMessage());
-        }
         bind(AccountInternalApi.class).toInstance(accountInternalApi);
         bind(ImmutableAccountInternalApi.class).toInstance(immutableAccountInternalApi);
     }
diff --git a/util/src/test/java/org/killbill/billing/mock/MockAccountBuilder.java b/util/src/test/java/org/killbill/billing/mock/MockAccountBuilder.java
index 65a54d9..c3c1316 100644
--- a/util/src/test/java/org/killbill/billing/mock/MockAccountBuilder.java
+++ b/util/src/test/java/org/killbill/billing/mock/MockAccountBuilder.java
@@ -25,6 +25,7 @@ import org.killbill.billing.account.api.Account;
 import org.killbill.billing.account.api.AccountData;
 import org.killbill.billing.account.api.MutableAccountData;
 import org.killbill.billing.catalog.api.Currency;
+import org.killbill.billing.util.account.AccountDateTimeUtils;
 
 public class MockAccountBuilder {
 
@@ -60,7 +61,6 @@ public class MockAccountBuilder {
     }
 
     public MockAccountBuilder(final AccountData data) {
-        this.id = UUID.randomUUID();
         this.address1(data.getAddress1());
         this.address2(data.getAddress2());
         this.billingCycleDayLocal(data.getBillCycleDayLocal());
@@ -80,6 +80,13 @@ public class MockAccountBuilder {
         this.postalCode(data.getPostalCode());
         this.stateOrProvince(data.getStateOrProvince());
         this.timeZone(data.getTimeZone());
+        if (data instanceof Account) {
+            this.id = ((Account) data).getId();
+            this.createdDate(((Account) data).getCreatedDate());
+            this.updatedDate(((Account) data).getUpdatedDate());
+        } else {
+            this.id = UUID.randomUUID();
+        }
     }
 
     public MockAccountBuilder externalKey(final String externalKey) {
@@ -206,109 +213,101 @@ public class MockAccountBuilder {
 
             @Override
             public String getName() {
-
                 return name;
             }
 
             @Override
             public Integer getFirstNameLength() {
-
                 return firstNameLength;
             }
 
             @Override
             public String getEmail() {
-
                 return email;
             }
 
             @Override
             public Integer getBillCycleDayLocal() {
-
                 return billingCycleDayLocal;
             }
 
             @Override
             public Currency getCurrency() {
-
                 return currency;
             }
 
             @Override
             public UUID getPaymentMethodId() {
-
                 return paymentMethodId;
             }
 
             @Override
             public DateTimeZone getTimeZone() {
-
                 return timeZone;
             }
 
             @Override
-            public String getLocale() {
+            public DateTimeZone getFixedOffsetTimeZone() {
+                return AccountDateTimeUtils.getFixedOffsetTimeZone(this);
+            }
+
+            @Override
+            public DateTime getReferenceTime() {
+                return AccountDateTimeUtils.getReferenceDateTime(this);
+            }
 
+            @Override
+            public String getLocale() {
                 return locale;
             }
 
             @Override
             public String getAddress1() {
-
                 return address1;
             }
 
             @Override
             public String getAddress2() {
-
                 return address2;
             }
 
             @Override
             public String getCompanyName() {
-
                 return companyName;
             }
 
             @Override
             public String getCity() {
-
                 return city;
             }
 
             @Override
             public String getStateOrProvince() {
-
                 return stateOrProvince;
             }
 
             @Override
             public String getPostalCode() {
-
                 return postalCode;
             }
 
             @Override
             public String getCountry() {
-
                 return country;
             }
 
             @Override
             public String getPhone() {
-
                 return phone;
             }
 
             @Override
             public Boolean isMigrated() {
-
                 return migrated;
             }
 
             @Override
             public Boolean isNotifiedForInvoices() {
-
                 return isNotifiedForInvoices;
             }
 
diff --git a/util/src/test/java/org/killbill/billing/util/callcontext/TestInternalCallContextFactory.java b/util/src/test/java/org/killbill/billing/util/callcontext/TestInternalCallContextFactory.java
index 311c7d6..9a5c01e 100644
--- a/util/src/test/java/org/killbill/billing/util/callcontext/TestInternalCallContextFactory.java
+++ b/util/src/test/java/org/killbill/billing/util/callcontext/TestInternalCallContextFactory.java
@@ -90,9 +90,9 @@ public class TestInternalCallContextFactory extends UtilTestSuiteWithEmbeddedDB 
     private void verifyInternalCallContext(final InternalCallContext context) {
         Assert.assertEquals(context.getCallOrigin(), callContext.getCallOrigin());
         Assert.assertEquals(context.getComments(), callContext.getComments());
-        Assert.assertEquals(context.getCreatedDate(), callContext.getCreatedDate());
+        Assert.assertTrue(context.getCreatedDate().compareTo(callContext.getCreatedDate()) >= 0);
         Assert.assertEquals(context.getReasonCode(), callContext.getReasonCode());
-        Assert.assertEquals(context.getUpdatedDate(), callContext.getUpdatedDate());
+        Assert.assertTrue(context.getUpdatedDate().compareTo(callContext.getUpdatedDate()) >= 0);
         Assert.assertEquals(context.getCreatedBy(), callContext.getUserName());
         Assert.assertEquals(context.getUserToken(), callContext.getUserToken());
         Assert.assertEquals(context.getContextUserType(), callContext.getUserType());
diff --git a/util/src/test/java/org/killbill/billing/util/timezone/TestDateAndTimeZoneContext.java b/util/src/test/java/org/killbill/billing/util/timezone/TestDateAndTimeZoneContext.java
index c37c115..724b802 100644
--- a/util/src/test/java/org/killbill/billing/util/timezone/TestDateAndTimeZoneContext.java
+++ b/util/src/test/java/org/killbill/billing/util/timezone/TestDateAndTimeZoneContext.java
@@ -23,8 +23,11 @@ import org.joda.time.DateTimeZone;
 import org.joda.time.LocalDate;
 import org.joda.time.format.DateTimeFormatter;
 import org.joda.time.format.ISODateTimeFormat;
+import org.killbill.billing.account.api.Account;
+import org.killbill.billing.mock.MockAccountBuilder;
 import org.killbill.billing.util.AccountDateAndTimeZoneContext;
 import org.killbill.billing.util.UtilTestSuiteNoDB;
+import org.killbill.billing.util.account.AccountDateTimeUtils;
 import org.testng.annotations.Test;
 
 import static org.testng.Assert.assertEquals;
@@ -49,9 +52,9 @@ public class TestDateAndTimeZoneContext extends UtilTestSuiteNoDB {
     @Test(groups = "fast")
     public void testComputeUTCDateTimeFromLocalDate1() {
         final DateTime effectiveDateTime = DATE_TIME_FORMATTER.parseDateTime(effectiveDateTime1);
-
         final DateTimeZone timeZone = DateTimeZone.forOffsetHours(-8);
-        internalCallContext.setReferenceDateTimeZone(timeZone);
+        refreshCallContext(effectiveDateTime, timeZone);
+
         final AccountDateAndTimeZoneContext dateContext = new DefaultAccountDateAndTimeZoneContext(effectiveDateTime, internalCallContext);
 
         final LocalDate endDate = new LocalDate(2013, 01, 19);
@@ -62,9 +65,9 @@ public class TestDateAndTimeZoneContext extends UtilTestSuiteNoDB {
     @Test(groups = "fast")
     public void testComputeUTCDateTimeFromLocalDate2() {
         final DateTime effectiveDateTime = DATE_TIME_FORMATTER.parseDateTime(effectiveDateTime2);
-
         final DateTimeZone timeZone = DateTimeZone.forOffsetHours(-8);
-        internalCallContext.setReferenceDateTimeZone(timeZone);
+        refreshCallContext(effectiveDateTime, timeZone);
+
         final AccountDateAndTimeZoneContext dateContext = new DefaultAccountDateAndTimeZoneContext(effectiveDateTime, internalCallContext);
 
         final LocalDate endDate = new LocalDate(2013, 01, 20);
@@ -75,9 +78,9 @@ public class TestDateAndTimeZoneContext extends UtilTestSuiteNoDB {
     @Test(groups = "fast")
     public void testComputeUTCDateTimeFromLocalDate3() {
         final DateTime effectiveDateTime = DATE_TIME_FORMATTER.parseDateTime(effectiveDateTime3);
-
         final DateTimeZone timeZone = DateTimeZone.forOffsetHours(-8);
-        internalCallContext.setReferenceDateTimeZone(timeZone);
+        refreshCallContext(effectiveDateTime, timeZone);
+
         final AccountDateAndTimeZoneContext dateContext = new DefaultAccountDateAndTimeZoneContext(effectiveDateTime, internalCallContext);
 
         final LocalDate endDate = new LocalDate(2013, 01, 20);
@@ -88,9 +91,9 @@ public class TestDateAndTimeZoneContext extends UtilTestSuiteNoDB {
     @Test(groups = "fast")
     public void testComputeUTCDateTimeFromLocalDateA() {
         final DateTime effectiveDateTime = DATE_TIME_FORMATTER.parseDateTime(effectiveDateTimeA);
-
         final DateTimeZone timeZone = DateTimeZone.forOffsetHours(8);
-        internalCallContext.setReferenceDateTimeZone(timeZone);
+        refreshCallContext(effectiveDateTime, timeZone);
+
         final AccountDateAndTimeZoneContext dateContext = new DefaultAccountDateAndTimeZoneContext(effectiveDateTime, internalCallContext);
 
         final LocalDate endDate = new LocalDate(2013, 01, 21);
@@ -101,9 +104,9 @@ public class TestDateAndTimeZoneContext extends UtilTestSuiteNoDB {
     @Test(groups = "fast")
     public void testComputeUTCDateTimeFromLocalDateB() {
         final DateTime effectiveDateTime = DATE_TIME_FORMATTER.parseDateTime(effectiveDateTimeB);
-
         final DateTimeZone timeZone = DateTimeZone.forOffsetHours(8);
-        internalCallContext.setReferenceDateTimeZone(timeZone);
+        refreshCallContext(effectiveDateTime, timeZone);
+
         final AccountDateAndTimeZoneContext dateContext = new DefaultAccountDateAndTimeZoneContext(effectiveDateTime, internalCallContext);
 
         final LocalDate endDate = new LocalDate(2013, 01, 21);
@@ -114,9 +117,9 @@ public class TestDateAndTimeZoneContext extends UtilTestSuiteNoDB {
     @Test(groups = "fast")
     public void testComputeUTCDateTimeFromLocalDateC() {
         final DateTime effectiveDateTime = DATE_TIME_FORMATTER.parseDateTime(effectiveDateTimeC);
-
         final DateTimeZone timeZone = DateTimeZone.forOffsetHours(8);
-        internalCallContext.setReferenceDateTimeZone(timeZone);
+        refreshCallContext(effectiveDateTime, timeZone);
+
         final AccountDateAndTimeZoneContext dateContext = new DefaultAccountDateAndTimeZoneContext(effectiveDateTime, internalCallContext);
 
         final LocalDate endDate = new LocalDate(2013, 01, 20);
@@ -131,11 +134,12 @@ public class TestDateAndTimeZoneContext extends UtilTestSuiteNoDB {
         final DateTime dateTime3 = new DateTime("2015-12-01T08:01:01.000Z");
 
         // Alaska Standard Time
-        final DateTimeZone tz = DateTimeZone.forID("America/Juneau");
-        internalCallContext.setReferenceDateTimeZone(tz);
+        final DateTimeZone timeZone = DateTimeZone.forID("America/Juneau");
 
         // Time zone is AKDT (UTC-8h) between March and November
         final DateTime referenceDateTimeWithDST = new DateTime("2015-09-01T08:01:01.000Z");
+        refreshCallContext(referenceDateTimeWithDST, timeZone);
+
         final AccountDateAndTimeZoneContext tzContextWithDST = new DefaultAccountDateAndTimeZoneContext(referenceDateTimeWithDST, internalCallContext);
         assertEquals(tzContextWithDST.computeLocalDateFromFixedAccountOffset(dateTime1), new LocalDate("2015-01-01"));
         assertEquals(tzContextWithDST.computeLocalDateFromFixedAccountOffset(dateTime2), new LocalDate("2015-09-01"));
@@ -143,9 +147,19 @@ public class TestDateAndTimeZoneContext extends UtilTestSuiteNoDB {
 
         // Time zone is AKST (UTC-9h) otherwise
         final DateTime referenceDateTimeWithoutDST = new DateTime("2015-02-01T08:01:01.000Z");
+        refreshCallContext(referenceDateTimeWithoutDST, timeZone);
+
         final AccountDateAndTimeZoneContext tzContextWithoutDST = new DefaultAccountDateAndTimeZoneContext(referenceDateTimeWithoutDST, internalCallContext);
         assertEquals(tzContextWithoutDST.computeLocalDateFromFixedAccountOffset(dateTime1), new LocalDate("2014-12-31"));
         assertEquals(tzContextWithoutDST.computeLocalDateFromFixedAccountOffset(dateTime2), new LocalDate("2015-08-31"));
         assertEquals(tzContextWithoutDST.computeLocalDateFromFixedAccountOffset(dateTime3), new LocalDate("2015-11-30"));
     }
+
+    private void refreshCallContext(final DateTime effectiveDateTime, final DateTimeZone timeZone) {
+        final Account account = new MockAccountBuilder().timeZone(timeZone)
+                                                        .createdDate(effectiveDateTime)
+                                                        .build();
+        internalCallContext.setFixedOffsetTimeZone(AccountDateTimeUtils.getFixedOffsetTimeZone(account));
+        internalCallContext.setReferenceTime(AccountDateTimeUtils.getReferenceDateTime(account));
+    }
 }