Fixed a few strange bugs
Fixed test