Simplified when(), added tests