addressed julienw's comment and add simple unit test