Catch ValueError. Move initialization in separate method
Add test for ValueError
Add tests for IOError and OSError