Fixed a bug + wrote some more tests