Move code only needed for testing to test helper

Move code to clear root folder from Folder model to a test helper
method, as this code is only needed for testing.