Improved tests and fixed bugs

Fixed #49 and improved tests for readability.