Cleaned up and added more test cases