* Reverts back previous fix and uses proper error handeling * Adds more tests and refactors existing tests