improve - extract before() method for unit test