major refactor

split file data into separate table, add DocumentFactory and FileFactory to eliminate code redundancy, add sample tests