Added extension methods and throwing exceptions, updated test cases