final code, updated test spec