When dealing with impure functions - extract to pure ones as much as possible. Use dependency injection - this will allow you to use different back-ends later.
Use external integration-testing (Robot, Cucumber, scripts, etc) for testing impure functions in your application