Adds tests; refactors fsclient.