FIXED: several crashing bugs
ADDED: some basic unit tests