Fixed bugs with automatic testing