Added some fault-tolerance to logging; added tests